Latest Posts Shortcode
Suppose you have a Page in WordPress with some company information, and you wanted to display some recent blog posts within it. Or maybe you have a FAQ section and you wanted to display some excerpts of other important items. The ‘Latest’ shortcode was created to remedy this problem and bring more dynamic content into your pages with minimal effort.
Example Using Columns
The example below shows how to use the latest shortcode to display your content within a set number of columns. If you’d like to use some of your own custom markup inside the shortcode, but still want to use columns, see the advanced example further below.
The Code
[latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="6" cols="2" cat="6"]
The Result
Sample Blog Post with Long Title for Testing Purposes
Advanced Example
Below is a more advanced example combined with the adaptive fractional columns shortcode, using custom markup within the shortcode.
Latest Posts from Category A
Latest Posts from Category B
Latest Posts from Category C
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Latest Posts from Category A
Latest Posts from Category B
Latest Posts from Category C
Source of Above Output
[one_third] <h5>Latest Posts from Category A</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="1" cat="11"][/one_third] [one_third] <h5>Latest Posts from Category B</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="1" cat="11" offset="1"][/one_third] [one_third_last] <h5>Latest Posts from Category C</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="1" cat="11" offset="2"][/one_third_last] [clearfade] Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. [break] [break] [clearfade] [one_third] <h5>Latest Posts from Category A</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="1" cat="6" offset="3"][/one_third] [one_third] <h5>Latest Posts from Category B</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More »" width="75" height="75" num="1" cat="6" offset="4"][/one_third] [one_third_last] <h5>Latest Posts from Category C</h5> [latest excerpt="true" thumbs="true" length="50" morelink="Read More" width="75" height="75" num="1" cat="8" offset="6"][/one_third_last]
Below is a list of the accepted parameters for the “Latest” shortcode and some examples to help you get started.
/*-----------------------------------------------------------------------------------*/ // // Latest Posts // Shortcode Parameters: // /*-----------------------------------------------------------------------------------*/ // excerpt="true|false" ------ display the excerpt or 'more' tag break // length="50" ------ excerpt character length // thumbs="true|false" ------ display featured thumbnail // width="50" ------ featured thumbnail width // cols="2" ------ split the results into X number of columns (4 max) // height="50" ------ featured thumbnail height // num="6" ------ number of entries to display // cat="1,-2" ------ categories to include or exclude (-) // morelink="Read More..." ------ more link text // offset="0" ------ offset/skip X number of posts // type="page|post" ------ query type // parent="1" (page only) ------ page parent // orderby="date|customfield" ------ custom ordering // order="ASC|DESC" ------ sort order /*-----------------------------------------------------------------------------------*/ // Example: [latest excerpt="true" thumbs="true" width="50" height="50" num="5" cat="8,10,11"] /*-----------------------------------------------------------------------------------*/