Simple:Press Documentation

Template Tag: Latest Posts

The Template Tag Latest Posts displays latest topic posts in the forum including multiple posts from one topic.

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_LatestPostsTag() and the file that makes the magic happen is sp-LatestPosts-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.

Options

  • 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 – class to be applied to list item style. This would be text. The default is spListItemTag.
  • textClass – class to be applied to text labels. This would be text. The default is spTextTag.
  • 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.
  • limit – How many topics to show in the list. This would be a number. The default is 5.
  • avatarClass – The class to be applied to avatar. This would be text. The default is spAvatarTag
  • itemOrder – This is entered as text. The Default is FTUD.
  • 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.

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 ‘&nbsp;-‘
  • 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.
  • 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

Usage

An example of using this tag with only default settings.

<?php sp_LatestPostsTag();?>

An example of using this tag with the item order set, The limit set to 10 and the HTML  <hr /> after the date.

<?php sp_LatestPostsTag('itemOrder=FTAUD&&limit=10&afterDate=<hr/>');?>

You can also call this function by using a shortcode on pages, posts or widgets.

[sp_latest_posts]

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


Copyright © 2006-2019 Simple:Press. All Rights Reserved.