[su_posts] shortcode is intended for display of posts, pages, and various post types. You can display posts from a specific category or by a specific tag. You can also choose multiple taxonomies and select the number of displayed posts. This shortcode uses WP_Query class.
The full list of shortcode's parameters can be found on the plugin page at Dashboard - Shortcodes - Available shortcodes - Posts.
Unfortunately, pagination is currently not available in the shortcode. This function will be added in future versions.
Built-in templates #
[su_posts] shortcode allows using various templates for display of posts. You can use several templates built into the plugin. Built-in templates are located in the
/wp-content/plugins/shortcodes-ultimate/templates/ folder. The list of built-in templates is given below:
default-loop.php- posts loop
teaser-loop.php- posts loop with thumbnails and titles
single-post.php- single post template
list-loop.php- unordered list with post titles
template attribute to change the template. The value of this attribute should be a relative path to template file from plugin folder or folder of your theme. Shortcode example:
In this example, search for the template will be made in the following locations (in the specified order):
Template editing #
Do not edit templates in the plugin folder, since all your changes will be lost after plugin update.
To change one of the built-in templates, you should copy it to the folder of your theme first. For convenience, you can copy the whole "templates" folder from plugin folder to the folder of your theme. Folder with templates may have other names than "templates". Resulting paths to template files should look like:
Now you can edit imported templates. As it was mentioned above, the plugin will search for a template file in the theme folder first.
Creating custom templates #
You can create your own templates for
[su_posts] shortcode, which makes it incredibly powerful. Your own templates should be created in the folder with your active theme. For example, you can create a folder "posts-templates" in the folder with your active theme. Create
my-loop.php file in this folder and place the following code in it:
<?php if ( $su_posts->have_posts() ) : while ( $su_posts->have_posts() ) : $su_posts->the_post(); echo '<h2>' . get_the_title() . '</h2>'; the_excerpt(); endwhile; else : echo 'Posts not found'; endif;
Now you can use the following shortcode to display posts with custom template: