The Template Tag Recent Posts displays the most recent topics to have received a new post.
This template tag is included in the Template Tags and Widgets plugin available on the Simple:Press Our Plugin Library page.
The function used is sp_RecentPostsTag() and the file that makes the magic happen is sp-RecentPosts-tag.php which is located in the plugin’s template-tags/library folder.
You can pass optional arguments to the function for formatting and display of special text or to show/not show specific items.
- tagId – A unique id to use for div or list. This would be text. The default is spRecentPostsTag.
- tagClass – The class to be applied for styling. This would be text. The default is spListTag.
- listClass – The class to be applied to list item style. This would be text. The default is spListItemTag.
- linkClass – The class to be applied to link style. This would be text. The default is spLinkTag
- textClass – class to be applied to text labels. This would be text. The default is spTextTag.
- avatarClass – The class to be applied to avatar. This would be text. The default is spAvatarTag
- listTags – Wrap in <ul> and <li> tags. This would be true or false. The default is true. If false a div will be used.
- forumIds – A comma delimited list of forum id numbers. This is optional. The default is all forums.
- topicIds – A comma delimited list of topic id’s. This is optional. The default is all forums.
- orderByGroup – Sets the display order of the the forums by their parent group. This would be a true/false option. The default is false.
- limit – How many topics to show in the list. This would be a number. The default is 5.
- itemOrder – This is entered as text. The Default is FTUD.
This parameter controls both which components are displayed and also the order in which they
are displayed. Use the following codes to construct this parameter. No spaces or other
characters can be used. Must be uppercase (Capital) letters.
F – Displays the forum name
T – Displays the Topic name
A – Displays the users Avatar
U – Displays the Users display name
D – Displays the date of the post
If not passed the default is FTUD – which does not include the users Avatar.
- linkScope – This is entered as text. The Default is ‘forum’.
This parameter controls what items are made into links (‘a’ tags): The following options
are available. NOTE that the Topic will ALWAYS be formed as a link:
forum – Display the Forum name as a link as well as the Topic
all – Make the entire entry a link to the Topi
- beforeForum – The text to display before the forum title. The default is ‘Forum: ‘
- afterForum – The text to display after the forum title The default is ‘<br />’
- beforeTopic – The text to display before the topic title The default is ‘Topic: ‘
- afterTopic – The text to display after the topic title The default is ‘<br />’
- beforeUser – The text to display before user The default is ‘By: ‘
- afterUser – The text to display after user The default is no text.
- beforeDate – The text to display before date The default is ‘ -‘
- afterDate – The text to display after date The default is no text.
- avatarSize – The Pixel size of avatar if showing. This is a number. The default is 25.
- niceDate – Show date as ‘nice’ date. This is a true/false. The default is true. See Codex here for description of niceDate.
- postTip – Option to include post content extract on link. This is a true/false. The default is true.
- truncate – truncate both forum and topic header – optional. Number of characters to truncate both the forum title and topic title down to. The default is 0 (zero) which means do not truncate.
- echo is a true/false expression using 1 as true and 0 as false. The default is true.
NOTE: True must be expressed as a 1 and False as a zero
An example of using this tag with only default settings.
An example of using this tag with the item order set, The limit set to show last 2 .
You can also call this function by using a shortcode on pages, posts or widgets.
[sp_recent_posts itemorder='FTAUD' limit='2']
The Using Plugins page describes how you obtain and install the Template Tags plugin. Once installed you would activate it from the Simple:Press administration page Available “Plugins – Install Simple:Press Plugins”
More Topics In SimplePress: Plugins