Loading content from posts (featured slides)

One of the most important features of Slider PRO is its ability to automatically fetch data from your posts. This allows you to create dynamic slides which update every time you insert a certain type of data. There are 3 types of dynamic slides: slides that are created by fetching data from your posts based on certain taxonomies and parameters, slides that are created using a post's gallery of images as a source, and slides that load photos from Flickr. In this article you will learn how to create slides that load content from posts.

First, you need to set the 'Slide Type' option to 'Posts Content'. When you do that, several controls will appear and you can use those controls to select from which posts the data will be fetched.

Post Types

From the 'Post Types' drop-down, you can select which posts to fetch data from. Here you will see the default post types: Posts and Pages, but also custom post types.

Post Taxonomies

Based on the selected post types, the taxonomies associated with those posts will appear in the 'Post Taxonomies' menu. Please note that the post types and taxonomies will appear only if they are attached to at least one post.

NOTE: For performance purposes, it's recommended to use as few taxonomy terms as possible. To avoid accidental or uninformed use of too many taxonomy terms, the slider will not allow the selection of more than 5 terms. In order to fetch posts, the slider uses a native WordPress function (i.e., WP_Query), and this function can become slow if you use too many taxonomy terms.

In practice, the situations when you need to use more than 5 taxonomy terms are very rare; most of the times, only one taxonomy term is used (e.g., fetching posts from one category, or posts that contain a certain tag). Here are some solutions when you think you need to use more taxonomy terms than the current limit:

  • When you want to load all posts from a certain post type, you actually don't have to select any taxonomy term; you only need to select the post type and the slider will load all posts from that type.
  • When you want to load almost all posts but exclude a few, you can select only the taxonomy terms attached to posts that you want excluded and set the 'Operator' option to 'NOT IN'.
  • When you want to filter posts based on more taxonomies and the situations described above don't apply, I recommend creating a new category or tag to be used inside the slider. For example, you create a 'my-slider' tag and add this tag to all posts that you want loaded in the slider. Then, inside the slider you select only the 'my-slider' tag.

Relation

The 'Relation' option will allow you to specify whether the posts need to have all the selected taxonomies or at least one of the selected taxonomies.

Operator

The 'Operator' option indicates whether posts that will be loaded need to have the selected taxonomy terms (IN) or need to not have them (NOT IN).

Order By

The 'Order By' option allows you to sort the slides based on the selected criteria and the 'Order' option will allow you to sort the slides in ascending or descending order.

Maximum

You can use the 'Maximum' option to indicate how many posts the data will be fetched from and the 'Offset' option to indicate the index/position from where the fetching will start.

Featured

The 'Featured' option is disabled by default because most of the times it's not needed. You can enable it from Slider PRO -> Plugin Options. This option will allow you to fetch data only from certain posts, posts for which the 'Feature this post' option was checked in the slider's metabox that appears on all posts. This box will appear only if the option is enabled.

IMPORTANT!

Setting the above options is the first step in creating the dynamic slide. The second step is to specify where the fetched content will be displayed. For example, you might want to have the featured image displayed as a main slide image, or you might want to display it somewhere in a layer. Also, you might want the title of the post to be used as an 'alt' attribute for the image or as a 'title' attribute.

The slider gives you the flexibility to choose where the fetched content will be displayed by providing you with several tags, which you will simply insert in the slide's fields. For example, if you want the slide image to appear as the main slide, you will insert [sp_image] in Image -> Path, or if you want the image to appear in a layer, you will enter [sp_image] somewhere in the Layers section.

Dynamic tags presentation

TagDescription
[sp_image] Returns the URL of the featured image, if it exists for the post, or of the first image from the post. It also has a 'size' argument which can take the following values: full, large, medium, small. You can use the 'size' argument to load the full image version as the main slide image and the small image as a thumbnail. Example: [sp_image size="small"]
[sp_image_alt] Returns the alt text of the image.
[sp_image_title] Returns the title of the image.
[sp_image_caption] Returns the specified caption for the image.
[sp_image_description] Returns the specified description for the image.
[sp_title] Returns the title of the post.
[sp_link] Returns the URL of the post.
[sp_date] Returns the data of the post in the format specified in Settings -> General -> Date Format.
[sp_content] Returns the content of the post. If the quicktag <!--more--> is used in a post to designate the "cut-off" point for the post to be excerpted, the [sp_content] tag will only show the excerpt up to the <!--more--> quicktag point. You can use the 'more_text' argument to set a certain text to be displayed instead of the default 'continue reading' text. Example: [sp_content more_text="Read More..."]
[sp_excerpt] Returns the excerpt of the post. You can use the 'limit' argument to set a limit for the number of characters that will be displayed. Example: [sp_excerpt limit="140"]
[sp_author_name] Returns the name of the post's author.
[sp_author_posts] Returns the URL to the author's posts.
[sp_comments_number] Returns the number of comments that a post has. By default, if there is no comment it will return 'No Comment', if there's a single comment it will return '1 Comment' and if there is more than one comment, it will return '% Comments'. However, you can specify your own custom text by using the 'zero', 'one' and 'more' arguments. Example: [sp_comments_number zero="No comments yet" one="Just a single comment" more="Plenty of comments"]
[sp_comments_link] Returns the URL to the post's comments.
[sp_custom name="property_name"] Returns the value of a custom property added in the post's custom fields. Example: [sp_custom name="product_price"]

Dynamic tags examples:

Load the featured image as a main image for the slide and set the 'alt' and 'title' attributes for the image.

Insert the post title, the date of the post and the excerpt of the post in the slide's layers.

Set the link of the main slide image to be the link of the post and set the link's title to the title of the post.

Please note that these are just a few variations. You can use the dynamic tags in any of the slide's fields and in any combination.

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk