Imagine you are building a beautiful web page with the BBE live editor. You add a some elements to the homepage, maybe that beautiful slider, or a video, a hard-thought copy illustrating your mission on earth….now you want to display a section with the latest posts / company news / blog updates. Typical!
While this can be achieved in a number of ways, we recommend using a built-in, powerful solution for accomplishing these kinds of tasks.
As you know BBE fully supports shortcodes, allowing them to be used and placed inside the page structure with ease. Of course, they will not be rendered upon page editing, but only after saving and quitting the editor.
The BBE Theme comes with a built-in shortcode to call posts. It’s name is bbe_postlist and it’s a powerful, flexible tool to complement your layouts with some fresh news extracted by category, if you want.
The basic syntax:
Please delete the white space between the left bracket and bbe_postlist – we just need it here 🙂
Let’s spice it up: the Parameters
Optionally, this shortcode can handle quite a lot of parameters, very useful in many cases such as:
- When you want to extract posts from a specific category or other criteria
- When you want to affect the way these posts are shown, eg including featured image or hiding dates, etc
- When you want to achieve special layouts: basically posts will stack vertically, but you may want to have them horizontally
To cover all these needs, here is a list of the available parameters, with their default assigned value:
These parameters control which posts will be called from the shortcode.
Geeks will like that these are the same that the get_posts function handles.
posts_per_page => 10
offset => 0
orderby => date
order => DESC
post_type => post
post_status => publish
suppress_filters => true
These parameters control the way posts are displayed – it’s a handy way to control their layout.
output_callback => bbetheme_postlist_default_callback This parameter is for advanced users – so that they can use a custom callback function for displaying posts
output_wrapper_class => Name of CSS class which will wrap the whole post list
output_article_class => Name of CSS class which will wrap each article
output_heading_tag => h2 Heading tag to use for the article title: typically, you may want to try h3,h4,h5 for smaller text
output_hide_elements => [ Used for hiding post elements – it defaults to none – but you can list here one or more comma separated elements chosen from this set: title, author, datetime, featured, excerpt, category, comments, clearfix ]
output_featured_image_before => Set to 1 to have the featured image before the post title
output_featured_image_format =>thumbnail Useful to set each post’s featured image format
output_featured_image_class => attachment-thumbnail img-responsive alignleft Useful to set each post’s image wrapper class