Configuring the Post Plugins
The post plugins, Similar Posts, Recent Posts, Random Posts, and Recent Comments, should work ’straight out of the box’. For example:
<?php similar_posts(); ?>
will display an unordered list of links to the five posts most relevant to the current one.
Similarly,
<?php recent_comments(); ?>
will show a list of the five most recent comments and their authors.
You can style the lists any way you like by playing with your theme’s CSS.
If the latest version of the Plugin Output Cache is installed the post plugins (apart from Random Posts) will have their output cached for efficiency.
But what if you want just three items in the list? Or what if you want to include an indication of how many comments each post has? You need to configure the plugin’s settings.
Options/Settings
Each of the post plugins has a Settings page which is accessible if you are logged in with the capability to manage options–in the role of administrator (WordPress 2+) or user level 8 or above (before version 2). All the settings are listed below. Most of the options apply to all of the plugins.
Beware of choosing settings which are contradictory (e.g., include and exclude the same post) or so restrictive as to reduce matches to zero (e.g., matching both the current post’s category and tags).
- Number of posts to show
- The default is 5.
- Number of posts to skip
- Allows you to start part way ‘down’ the list of posts. For example, you could call Recent Posts twice, once with skip set to 0 and once set to 5 to produce a two-column listing. The default value is 0.
- Omit current post?
- On some occasions you may want the current post to be dropped from the output. By default Similar Posts omits the current post while the other post plugins include it.
- Show password-protected posts?
- By default posts which are password-protected are not shown but they can be included by setting this option.
- Show static pages?
- WordPress has static pages as well as the normal flow of posts. You can choose to show both pages and posts or either one alone. By default, only posts are included.
- Show attachments?
- WordPress stores attachments (or links to them) among normal posts and pages. You can choose to show them if you wish. By default, they are not included.
- Show by status
- WordPress assigns posts a status, e.g., whether they are published or not. This option lets you display posts with chosen states: published, draft, private, and future.
- Ignore posts older or newer than…
- Sometimes it is useful to only include posts that are more than, or less than, a certain number of days, months, or years old. A news site might want to show random posts from the last week, for example.
- Match posts by custom field
- If you wish you can use the very flexible post-meta system to select posts. At the most basic you can limit matches to posts where a specific custom field exists. You can also check that a custom field has a certain value. The ‘LIKE’ operator can be used with wildcards (’_’ matches any single character, ‘%’ matches zero or more characters). You can even use the MySQL REGEXP operator for complex matches. Please bear in mind that matching by custom field may slow down the plugin considerably.
- Limit matches to same category?
- By default, posts from any category are included but it can sometimes be useful to restrict the display to just those posts which share at least one category with the current post.
- Match the current post’s tags
- This option (only available for WordPress 2.3+) uses the current post’s tags to restrict the output. It can look broadly for posts with any of the tags, or strictly for all of the tags. If the current post is untagged or there are no matching tags the normal output is produced
- Match the current post’s author
- This option let’s you restrict output to posts which share the current post’s author
- Default display if no matches
- Occasionally, for whatever reason, a plugin has no items to display. By default it displays instead the text
'None Found'but you can change the message to fit your blog or language. You could even include a link,say, to your ‘about’ page. The before and after settings are ignored but if you embed output tags they will be expanded. - Show nothing if no matches
- As an alternative to displaying a default message, this option causes the plugin to produce no output at all.
- Text and codes before the list
- Lets you specify text and HTML before the list of items, e.g., to title the list. By default
<ul>is used. - Text and codes after the list
- Lets you specify text and HTML after the list of items. By default
</ul>is used. - Output template
- The output template specifies what gets displayed for each item in the output. For example, the default output template for Recent Posts is
<li>{link}</li>. Read from left to right it governs the output for each item in the list of recent posts. In this case it is a beginning and ending HTML list tag with something in between. The code, {link}, gets expanded for each item — and displays the post’s permalink with the post title as the text and the date of posting as the ‘tooltip’.
The output template treats anything between ‘{’ and ‘}’ as a special instruction or tag. A full list of output tags is given below. The tag system allows you to customise the plugin’s output to a high degree, for example,
<dt>{link} by {author} ({commentcount} comments)</dt><dd>{snippet:50} ...</dd>
outputs each item as part of a definition list showing the permalink, the author, and the number of comments the post has, followed by a 50-character snippet of the content and a trailing ellipsis.
The exact way these elements are displayed depends on your theme’s CSS. Applies to each plugin. - Text to trim at start replaced by ‘divider’
- usually the plugin output will be some kind of list with each element sandwiched between matching tags. Sometimes, though, you might want to have the output separated rather than wrapped: a comma-separated sequence of items would be an example. The output template
', {link}'would basically do the trick but would produce an unwanted', 'at the front of the first item. This option lets you enter', 'and have the offending comma and space trimmed neatly out of existence. - Divider
- usually the plugin output will be some kind of list with each element sandwiched between matching tags. Sometimes, though, you might want to have the output divided rather than wrapped: a comma-separated sequence of items would be an example. The output template
'{link}'would basically do the trick but with divider set to ‘, ‘. - Authors to exclude/include
- By default the plugin selects posts with no attention to who wrote what. By checking the appropriate boxes you can include or exclude posts by certain authors.
- Posts to exclude
- By default the plugin considers all matching posts in preparing its output. By including a comma-separated list of post IDs you can exclude particular posts from consideration.
- Posts to include
- By default the plugin considers all matching posts in preparing its output. By including a comma-separated list of post IDs you can only consider particular posts.
- Categories to exclude/include
- By default the plugin selects posts without caring how they are categorised. By checking the appropriate boxes, however, you can exclude or include posts in certain categories.
- Tagging
- This option (available for WordPress 2.3+) lets you specify a tag or list of tags to filter the output. For example, TAG A selects any post with that tag; TAG A, TAG B selects any post with either tag; and TAG A + TAG B selects only posts with both tags.
- Other plugins’ tags to remove from snippet
-
If {snippet} is present in the output template the plugin tries to produce a simple glimpse of the post’s content without HTML or markup. However, many plugins insert pseudo-tags of their own which can mess up the snippet. If you want these tags to be fully expanded you can use the {excerpt} output tag instead but if you simply want them cut out from your post you can specify a set of opening and closing pseudo-tags to be removed.
For example,'[tag]'and'[/tag]'will cut out the whole of'[tag]embedded stuff[/tag]'while'['and']'will remove'[insert stuff here]'. In these examples it would be very important to place'[tag]'above'['so they are removed in the right order. Pseudotags which contain modifiers, e.g.,[quote comment=12], can be removed with the aid of a wildcard, e.g.,[quote.*]. - Content filter
- Ordinarily, the plugin’s output is displayed wherever you place the tag in your template or, alternatively, where you place the corresponding widget. This option offers a third method of placement: a filter which looks for embedded tags in content. For example, the tag
<!--SimilarPosts-->placed in the body of a post would be replaced by a list of similar posts. This lets you insert plugin output on a post by post basis. Use<!--SimilarPosts-->,<!--RandomPosts-->,<!--RecentPosts-->, or<!--RecentComments-->.
Note: even when the content filter is active the tags will not be expanded if they are being shown via one of the plugins, e.g., if Recent Posts is showing the excerpt of a post with a tag in it, the tag cannot be expanded with infinite recursion. - Sorted/Grouped Output
- Each plugin produces a number of items sorted in the most useful manner for that plugin but you might want to sort the items differently. With these options you can sort the output according to the value of any (combination) of the output tags (though obviously some tags make little sense). You can sort in ascending or descending order and, where relevant, ignore case or not.
These options let you choose two levels of sorting. Items will be sorted by the first set and then by the second. It is also possible to specify a group template so that groups of items which sort together can be titled appropriately.
- Group title template
- This ‘title’ for each sorted group of items is specified in exactly the same manner as the output template. It appears whenever the primary sort tag changes.
The following options are only available in Similar Posts:
- Maximum number of words to use for match
- By default Similar Posts selects 20 words from a post to make its matches but this value can be adjusted to give the best results for your blog.
- Relative weight of post title, content, and tags
- Similar Posts lets you adjust the contribution the current post’s title, content, and tags make when looking for a match. The three numbers are specified as percentages and should add up to 100. Choose what works best for your particular set of posts.
- Manual links
- If this option is switched on you can use custom fields to override the automatic matching algorithm. From the write/edit screen enter a custom field named ’sp_similar’ with the ID of the post or page to which you wish to make a manual link. Multiple links can be made with a comma-delimited list of IDs.
- Term extraction algorithm
- The quality of the automatic matches depends on the extraction from a post’s content of key terms which represent the post’s meaning. The original algorithm uses relative word frequency to pick terms. You can also choose a more sophisticated method which uses TextRank to extract key terms. In general this leads to better similarity scores but that may or may not correspond to the user’s sense of similarity.
- Add output to feeds
- Appends a similar posts list to feeds. Previously this was handled by a separate plugin.
The following options are only available for Recent Comments:
- Type of comment to show
- In addition to ordinary comments there are trackbacks and pingbacks. By default Recent Comments only displays ordinary comments but you can choose to show all kinds of comment or just trackbacks and pingbacks.
- Type of grouping
- The list of recent comments is usually displayed according to the order in which the comments were made but sometimes you might want to group comments by post or by commenter. If you choose to group the comments you may well want to give each group a heading using the group template. (This option is a specific case of the many ways of sorting the output — basically it overrides any sorting options)
- Show just current post
- Sometimes you want to only list comments for the current post.
- Omit author comments
- By default the plugin lists all comments but you might want to exclude comments by the author of the post itself. Note that this option relies on the author being logged in while commenting.
- Omit user comments
- By default the plugin lists all comments but you might want to exclude comments by registered users of your blog. Note that this option relies on the author being logged in while commenting.
The following option is only available for Recent Posts:
- Select posts by date modified
- Instead of the usual behaviour of ordering output by date of creation you can chose to select the posts which have been changed most recently.
Output Template Tags
Several output template codes or tags were mentioned above. They offer a very flexible way to tell the plugin what aspects of a post to display and new tags are easily added to extend a plugin.
For example, {author} expands to the name of the post’s author and {date} becomes the date the post was created. An output template of 'by {author} on {date}' might expand, for example, to ‘by Rob on January 1, 2007′. Dates, however, can be expressed in different ways. By default {date} uses the same date format as the blog but if you wanted a different format you could specify it as a kind of parameter to the {date} tag. For example {date:Y} would just give the year in 4-figure format.
The general form for an output template tag is '{tagname:parameter1:parameter2:...}', where the curly brackets identify the tag as a tag, the ‘tagname’ picks out the tag from a list of valid tags, and the optional ‘:parameter’ allows some output tags to be fed extra data. If a tag can take a parameter and none is supplied a default value is used and if a tag cannot handle a parameter and one is supplied it is ignored.
The various output tags call the same internal filters as WordPress does so that, if, for example, you have installed a plugin to translate foreign-language characters, the plugin output should also be translated.
The current list of tags is as follows (colon indicate the tag has parameters)
- {title:maxlength:method}
- The post’s title. If maxlength is specified the title wraps after that many characters. Method can be ‘wrap’, ‘chop’ (which simply truncates), ‘trim’ (which chops but adds an …), or ’snip’ (which puts the ellipsis in the middle.
- {url:maxlength:method}
- The post’s permalink as a url. See {title} for parameters.
- {postid}
- The ID column of the post’s entry in the database.
- {author:method}
- The name of the post’s author. The default method ‘display’ uses the author’s display name; ‘first’ uses the first name; ‘last’ the last name; ‘full’ is equal to ‘first last‘; and ‘reverse’ to ‘last, first‘.
- {authorurl}
- The url of the permalink to the archive of the author’s posts.
- {date:format}
- The date the post was created — a date format can be specified or the blog’s default will be used, e.g.
{date:Y, F}would print something like ‘2007, January’. A format of ‘raw’ gives a value sueful for sorting. - {datedited:format}
- The date the post was last edited. See {date} for parameters.
- time:format}
- The time the post was created. See {date} for parameters.
- timeedited:format}
- The time the post was last edited. See {date} for parameters.
- {excerpt:maxwords:method:more:link}
- An excerpt of the post. Maxwords is the desired size of the excerpt (defaults to 55). Method, which can be ‘a’ or ‘b’ governs the way the excerpt is generated: ‘a’, the default, uses the same method WordPress itself employs, taking the post excerpt if available or the post content if not, stripping tags and then truncating to length; ‘b’, respects embedded
'<span id="more-523"></span>'tags and tries much harder to preserve formatting. The more parameter, which only applies to method b, lets you specify the text and codes to append to the output (by default, ‘ …’). If the link parameter is ‘link’ whatever you have chosen in more will be linked back to the post. - {snippet:maxlength:method:more:link}
- A lightweight extract from the post, stripped of tags (and pseudotags). For example, {snippet:50} gives a snippet 50 characters long. The default is 100. Method defaults to ‘char’ but can also be ‘word’ which measures in words instead. Both approaches attempt to handle multibyte characters correctly. See {excerpt} for other parameters.
- {fullpost}
- Delivers the full post with all relevant filters applied.
- {categorynames:separator}
- The names of the post’s categories, e.g., {categorynames: | } might produce ‘wordpress | plugins’. Note that the separator parameter needs no quotation marks.
- {categorylinks:separator}
- As above but with hyperlinks to the appropriate category pages
- {categoryid}
- The ID of a post’s principal category, i.e., if a post has several categories in the same hierarchy it chooses the most specific; if a post has more than one category the first (i.e., numerically smallest) is chosen. This is most useful when posts have only single categories and can be employed, for example, to display specific icons etc.
- {commentcount:zero_text:one_text:more_text}
- The number of comments associated with the post. If the extra parameters are supplied different text will be used according to how many comments, e.g., {commentcount:no comments:comment:comments} will give ‘no comments’, or ‘1 comment’, or ‘2 comments’. If the parameters are not supplied a bare numeral is output.
- {link:maxlength:method}
- Shorthand for
'<a href="{url}" rel="bookmark" title="{date}">{title:maxlength:method}</a>' - {custom:name}
- The contents of the custom field with the given name. Useful in cooperating with the many other plugins which use custom fields.
- {tags:separator}
- The post’s tags. For example, {tags:|} might give ‘wordpress|plugins’. The default separator is ‘, ‘.
- {taglinks:separator}
- The post’s tags as clickable links to the relevant tag pages. The default separator is ‘ ‘.
- {totalposts}
- The number of posts in the blog.
- {totalpages}
- The number of pages in the blog.
- {php:code}
- The output generated by treating code as genuine PHP. This powerful tag should be used with great care as it allows arbitrary code to be executed. You can, for example, incorporate WordPress template tags or other plugin tags into your output.
Write your code as though echoing to output and be careful to remember your semicolons, e.g.,
{php:$s=' '.strtoupper("hello world").' '; echo $s;}
The {php} has access to the$resultobject variable which contains the values of the columns of wp_posts for the post in question, e.g.,$result->IDis the post’s ID.
Putting{php:random_posts();}as what to display if no real matches are found provides a fallback display.
You can also include other output tags in your PHP code: just remember that they are not PHP variables but evaluate to literal text and may need to be wrapped in the appropriate quotation marks. - {postviews}
- Tries to discover how often a post has been viewed by using any of a number of popular plugins. Let me know if the plugin you use isn’t catered for.
- {image:number:width:height:timing:link:default}
- An
<img>element, if any exists, from a post’s content. By default, the first image is chosen butnumbercan be used to select another (counting from 0 as the first). If width and height are given (as pixels) the image is scaled accordingly, otherwise it displays full size. If the height is omitted width is used to define a square bounding box into which the image must fit. If either width or height is given as ‘?’ the other of the pair is taken as fixed and the image scaled accordingly. The value of timing decides whether the image is extracted before or after WordPress applies its filters to the post content. The default is ‘pre’ but ‘post’ can be specified when, for example, a gallery plugin inserts images only after processing. If the link parameter is given as ‘link’ then only images wrapped in links will be extracted and displayed. Finally, the default parameter can be used to give an<img>tag to output if no ne is found in the content. - {image:number:timing:suffix}
- An image location, if any exists, from a post’s content. By default, the first image is chosen but
numbercan be used to select another (counting from 0 as the first). The value of timing decides whether the image is extracted before or after WordPress applies its filters to the post content. The default is ‘pre’ but ‘post’ can be specified when, for example, a gallery plugin inserts images only after processing. The suffix parameter lets you add a string to the end of the image’s name, e.g., {imagesrc:0::xxx} might return ‘http://path/photoxxx.jpg’ instead of ‘http://path/photo.jpg’. There are two special values of suffix, ‘?t’ and ‘?m’ which use the current settings for thumbnail and medium image sizes to give the name of a reduced image, e.g., {imagesrc:0::?t} might give ‘http://path/photo-150×150.jpg’.
In addition, Recent Comments, has the following tags
- {commentexcerpt::maxwords:method:more:link}
- An excerpt from the comment, applying filters, and stripping tags (apart from smilies if they are activated). For example,
{commentexcerpt:20}would give a 20 word excerpt. The default is 55. See {excerpt} for the further parameters. - {commentsnippet:number of characters:method:more:link}
- A lightweight extract from the comment, stripped of tags. For example, {commentsnippet:50} gives a snippet 50 characters long. The default is 100. See {excerpt} for the further parameters.
- {commentdate:format}
- The comment’s date (local timezone). See {date} for parameters.
- {commenttime:format}
- The comment’s time (local timezone). See {date} for parameters.
- {commentdategmt:format}
- The comment’s date (UTC/GMT). See {date} for parameters.
- {commenttimegmt:format}
- The comment’s time (UTC/GMT). See {date} for parameters.
- {commenter:maxlength:format}
- The comment author’s name. See {title} for parameters
- {commenterurl:maxlength:format}
- The url left by comment author. See {title} for parameters.
- {commenterlink:maxlength:format}
- A link to the comment author’s url or, if none was given, just the commenter’s name. See {link} for parameters.
- {commenterip}
- The IP address of the commenter. It can be used, for example, to display an appropriate national flag.
- {commenturl}
- The comment’s permalink as a url.
- {commentpopupurl}
- The url to include in a link to open the comment popup window if the theme allows such.
- {commentlink:text}
- Shorthand for
'<a href="{commenturl}" rel="bookmark" title="{commentdate} at {commenttime}">{commenter} commented on {title}</a>'an alternative to the ‘ commented on ‘ bit can be supplied as the text parameter. The {title} tag is wrapped in a span with class ‘rc-title’ and the {commenter} in a span with class ‘rc-commenter’, so that they can be styled by CSS.'<li>{commentlink}</li>'is the default output template for Recent Comments. - {commentlink2:text}
- Shorthand for
'<a href="{commenturl}" rel="bookmark" title="{commentdate} at {commenttime} on {title}">{commenter}</a> - {commentexcerpt}…'. - {gravatar:size:rating:default}
- Displays a globally recognised avatar based on the commenter’s email address. By default, size is 96px. The ‘default’ parameter lets you specify the uri of an image to use when the commenter has no gravatar. Alternatively, you can specify ‘wavatar’, ‘monsterid’, or ‘identicon’ to have an individualised image returned as default.
Similar Posts, has one tag all to itself:
- {score}
- A measure of similarity ranging from 0 to (very) roughly 100 for an identical post.
There is one special tag which can be used in each plugin:
- {if:condition:yes:no}
- Lets you specify output conditionally according to the boolean value of condition. If condition evaluates to true the value of yes is output, otherwise the value of no. If yes and/or no are not given they default to the blank string. The condition must be a valid PHP expression; it can use WordPress or plugin functions; it has access to the $result object giving the contents of the current item’s row of the posts table; it can even contain further output template tags (but only one level of nesting of ‘{}’ is allowed.
In addition, yes and no can contain output template tags of their own. For example, you might want to produce different output depending upon whether the current item is a page or a post:
{if:is_page():{date}:{dateedited}}
Notice the nested tags with {} within {}. Only one level of nesting is allowed.
Overriding the Options Page
Using the Options/Setting page and, in particular, the output template, the behaviour of each plugin can be fine-tuned in many different ways. But what if you wanted to use, say, Similar Posts in more than one place in your blog. You might want to have a comma-separated list of three related posts under each post on your blog’s front page but an unordered list of 5 related posts in the sidebar of your single-post pages. Somehow you need to give each use of the function different instructions.
Let’s start easy. Suppose we have set up our settings page to deliver the three links under each post of the main page. We can just use similar_posts() in the right place to get that effect but then we need to override those options when we call similar_posts in the sidebar. We can override an option by passing a ‘query-string style’ argument list to the plugin template tag, e.g., similar_posts('limit=5') tells the plugin to show 5 items rather than three.
To override more than one option at once an ‘&’ is used. In our case we need to override three options: ‘limit’, ‘output_template’, and ‘divider’ (the full list of option names is given below), i.e.,
'limit=5&output_template=<li>{link}</li>÷r='.
Notice that 'divider=' assigns an empty string to the option.
It might happen that you need to specify a value that already contains an ‘&’. In that case you can override the default separator by making the query-string begin with ‘&’ followed by whatever character you want to use in its place, e.g.,
'&|title=Bed & Breakfast|limit=10'.
The full list of parameters is as follows:
- limit
- the maximum number of posts to show
- skip
- how many posts to skip before listing
- just_current_post (for Recent Comments only)
- restrict output to the current post
- omit_current_post
- exclude the current post from output
- show_private
- include password-protected posts (true/false)
- show_pages
- include static pages (false/true/but)
- show_attachments
- include attachment pages (false/true)
- status-publish
- include published posts(false/true)
- status-private
- include private posts(false/true)
- status-draft
- include draft posts(false/true)
- status-future
- include future posts(false/true)
- match_cat
- restrict matches to current post’s categories (true/false)
- match_tags
- restrict matches to the current post’s tags (false/any/all)
- match_author
- restrict matches to the current post’s author (true/false)
- show_type (for Recent Comments only)
- which comments to show (all/comments/trackbacks)
- num_terms (for Similar Posts only)
- number of words used to generate matches
- weight_title (for Similar Posts only)
- weight given to title (0.0 — 1.0)
- weight_content (for Similar Posts only)
- weight given to content (0.0 — 1.0)
- weight_tags (for Similar Posts only)
- weight given to tags (0.0 — 1.0)
- hand_links (for Similar Posts only)
- whether to check for manual links (true/false)
- term_extraction (for Similar Posts only)
- the algorithm to use to get key terms (frequency/pagerank)
- none_text
- what to show if no posts match
- no_text
- no output at all if no posts match (true/false)
- prefix
- text and code before the list
- suffix
- text and code after the list
- output_template
- what to display
- divider
- text or codes between items
- date_modified (for Recent Posts only)
- select output by date modified not date created (true/false)
- group_by (for Recent Comments only)
- how to group list of comments (none/post/author)
- group_template
- what to display before each group of comments
- tag_str
- select posts by tag; ‘taga, tagb’ selects posts with either tag; ‘taga + tagb’ selects posts with both tags
- excluded_posts
- comma separated list of post IDs to exclude
- included_posts
- comma separated list of post IDs to include
- excluded_authors
- comma separated list of author IDs to exclude
- included_authors
- comma separated list of author IDs to include
- no_author_comments (for Recent Comments only)
- omit comments by the post author (true/false)
- no_user_comments (for Recent Comments only)
- omit comments by the post author (true/false)
- excluded_cats
- comma separated list of category IDs to exclude
- included_cats
- comma separated list of category IDs to include
- content_filter
- scan posts for embedded tags (true/false)
- age-direction
- (before/after/none)
- age-length
- how long a time
- age-duration
- (day/month/year)
- custom-key
- name of custom field
- custom-op
- comparison operator (=,!=,>,>=,<,<=,LIKE,NOT LIKE, REGEXP, EXISTS)
- custom-value
- value of custom field
- sort-by1
- output tag(s) to sort by
- sort-order1
- SORT_ASC or SORT_DESC
- sort-case1
- ‘true’ or ‘false’
- sort-by2
- output tag(s) to sort by
- sort-order2
- SORT_ASC or SORT_DESC
- sort-case2
- ‘true’ or ‘false’
Extending the Plugins by Adding Your Own Output Template Tags
Let’s say you have another plugin that generates output which you want to include in your recent posts list. It’s actually an easy job–it just means adding a your own code in one place.
Each template tag is defined in the library file /post-plugin-library/output_tags.php as a function with the name ‘otf_tagname‘. So, for example, the {postid} output tag corresponds to the function otf_postid(). The function signature is as follows:
function otf_postid ( $option_key, $result, $ext ) { ... }
where $option_key is the key to the plugin’s options (via get_option()), $result is the particular row of the query result as an object with all the database columns available, e.g., $result->ID or $result->post_title, and $ext is the ‘extra’ data passed along to the tag after the colon. Each output tag function returns the tag value as a string.
Looking over the existing output tags should give you the idea.
Frequently Asked Questions
-
I’ve just upgraded to Similar Posts version 2.5 and it can’t find any matching posts: all I see is ‘None Found’.
This is probably because the necessary database table was not created for some reason. Make sure you have the latest version of Similar Posts. Try deactivating and then reactivating.
If that still fails try creating the table manually using the SQL below (for example in phpMyAdmin):
CREATE TABLE IF NOT EXISTS `wp_similar_posts` (
`pID` bigint( 20 ) unsigned NOT NULL ,
`content` longtext NOT NULL ,
`title` text NOT NULL ,
`tags` text NOT NULL ,
FULLTEXT KEY `title` ( `title` ) ,
FULLTEXT KEY `content` ( `content` ) ,
FULLTEXT KEY `tags` ( `tags` )
) ENGINE = MyISAM CHARSET = utf8;If your table prefix is not ‘wp_’ change the code above to match. If the above query causes an error try:
CREATE TABLE IF NOT EXISTS `wp_similar_posts` (
`pID` bigint( 20 ) unsigned NOT NULL ,
`content` longtext NOT NULL ,
`title` text NOT NULL ,
`tags` text NOT NULL ,
FULLTEXT KEY `title` ( `title` ) ,
FULLTEXT KEY `content` ( `content` ) ,
FULLTEXT KEY `tags` ( `tags` )
) ENGINE = MyISAM;Make sure you reindex after creating the table.
-
I’m trying Similar Posts on a new site. Everything seems to be properly installed but it says ‘None Found’ when I know there should be matches.
If it is a new site you probably only have a few posts so far. The way the database searches for matches can seem a little strange when there aren’t many posts. For example any words found in more than half the number of posts are ignored. Remember, too, that only words longer than three letters are counted.
I recommend you add a number of real, different, and normal-sized posts and you should begin to see Similar Posts working correctly.
Another possible cause for few or no matches showing is that your settings may be too restrictive, in particular opting to match categories and/or match tags can really narrow down the chances of a match. Try less demanding settings — if you want to reset the default options you can remove the plugin from the settings menu and then reactivate.
-
I get some strange values for {score}. Sometimes it’s well over 100 and sometimes it can be as small as 8 or 9 for posts that seem quite similar.
MySQL reports only the relative similarity of posts rather than some absolute number. The score depends on a number of factors. I have tried to scale the value of {score} so that it is very roughly 100 for a post’s similarity to itself — but even that is affected by too many variables to be more than a rough estimate.
-
How do I include a list of similar posts in my feeds?
Just switch on the option (Settings|Similar Posts|Other) to add Similar Posts to feeds. A new settings menu will appear with a full set of options for the feed.
-
Why, when I use Similar Posts as a widget, does it always gives the same list of posts?
You are probably using a WordPress version below 2.5 and one of the built-in widgets like Recent Posts or Recent Comments. Both widgets do their work by running a a new wp_query and in the process they destroy the context Similar Posts needs to function correctly. I thought this has been fixed in WordPress 2.5 but maybe not.
One workaround is to replace the built-in widgets with my own ;-)
-
Where have my keywords gone to? I can’t find the custom field ’similarterms’.
Version 2.5 uses a separate table rather than custom fields. If you are looking to influence similarity consider tagging your posts.
-
How do I get it so that {link} displays the date instead of the title? If i use the {date} template tag, it shows the date but no link.
You need to use the output template to tell the plugin exactly what to display. For example, if you want a link where the visible text shows the date of posting you could try:
<li><a href="{url}">{date}</a></li> -
How do I format the output of the {date} tag?
The blog’s date format is used by default but you can change it by adding a format string. The Codex has a page on format strings. Let’s say you want the date to look like Sunday, January 14, 2007. The correct format string is ‘l, F j, Y’ so you would write
{date:l, F j, Y} -
I don’t want my post plugin widget to show on the main page, just the single post page. Is that possible?
Yes. The widgets now let you choose the condition under which they are visible. The condition can be set using any combination of WordPress Conditional Tags, e.g., ‘is_home()’, ‘is_category()’, or ‘is_page()’.
In this case the right condition is ‘is_single()’.
-
I’m trying to place the plugin output just after a single post but other plugins seem to get in there first. Any ideas?
Some plugins automatically tack on their output to the end of a post’s content. The only way to get something in between is to hope that those plugins offer a way to turn off that kind of behaviour and let you explicitly place their output with a template tag. The good news is that most plugins are cooperative.
-
I found a script that allows me to put thumbnail images [or anything else] with each post. I was wondering if there was a way to integrate that with this plugin?
If the script stores the thumbnails in a custom field you can use the output template tag {custom} to display them. Try
something like:<img src="{custom:thumbnail}" alt="{custom:thumbnail-alt}" />A similar thing can be done with many other plugins.
-
I want to show the same plugin in two different places but with different output: can I?
Yes. Decide on one of the output templates and other settings you need and set them up from the options pages. The other invocation of the plugin then gets called with passed parameters to get the different output.
e.g.,random_posts('limit=3&output_template={custom:another_field}') -
I want an output template tag to do xxxxxx. How do I invent one?
You have two choices: a) modify the output_tags.php in the post-plugin-library; b) use the {php} tag.
If you go down route (a) (which is actually very easy) please let me know the new tag and I’ll maybe include it in the next version. If you use the {php} tag do be careful not to start WWIII. -
I uninstalled one of your plugins and now my whole sidebar has disappeared. How do I get it back?
You have probably forgotten to remove the code calling the plugin, e.g., recent_posts();.
I find a good practice is to use something like:if (function_exists('recent_posts')) { recent_posts(); }That way, if I ever deactivate a plugin temporarily the website doesn’t fall apart.
439 Comments Add your own
1. shedmore | February 8th, 2008 at 1:24 am
Hello I am noticing that when I use {link}{excerpt:10} it works great !…but if there is a break between an image (that lies above all text in the post) it picks up the break, and converts it into a slight indentation in the recent post excerpt…is there anyway to filter that out of the excerpt?
I use a break to pad the text below images on posts regularly, and the small indentation is a bit akward looking
Thanks!
2. Rori | February 8th, 2008 at 4:38 am
I can’t figure out how to make this not conflict with the recent posts widget in my theme.
I want one recent posts that shows all posts and one that shows only the posts from one category.
Can this one do that?
3. Rob | February 8th, 2008 at 10:18 am
shedmore: Perhaps the quickest way would be to do it with CSS — if you can isolate just the break in the context of the plugin output and set it to not display.
4. Rob | February 8th, 2008 at 10:28 am
Rori: I’m wondering whether the widget is the built-in one or my plugin as widget?
When you are using my plugin as a widget you can set whatever options you like but it will show up everywhere according to those options.
If, however, you insert the plugin directly into your template you can do two things: first, you can use the WordPress functions like is_single to decide what shows on which pages; and second, you can pass a parameter to the plugin template tag adjusting the options in any way you want. The details are set out above.
Good luck!
5. Mark Tyhurst | February 15th, 2008 at 4:11 pm
Hello, I am kinda new to all of this. I have the plugin successfuly installed and working just like I want it except I would like to see an excerpt of the recent post that it pulls. When I get the excerpt to show I would like to link the excerpt to the categorie instead of just going to the post. Is this possible? Can anyone help me? This is the code I am using…
TV
Movies
Remembering
6. Mark Tyhurst | February 15th, 2008 at 4:13 pm
maybe this will work…
7. Rob | February 15th, 2008 at 6:18 pm
Mark Tyhurst: Maybe you want to start with an output template like:
8. Mark Tyhurst | February 15th, 2008 at 7:03 pm
I am sorry I am not sure where to put the code that you specified above. Any advice where I should put it? Thanks so much!!!
9. Rob | February 15th, 2008 at 9:53 pm
Mark: Look on the Options page in the WordPress Admin section. There is a place to enter the plugin output template.
10. Kinda | February 15th, 2008 at 11:28 pm
Hello,
I don’t understand the difference between “excerpt” and snippet :-?
I find your plugin very good, but is it possible that the snippet/extract show the part of the post that “match” with the “post title words”, or with the word that are the most related.
For exemple in google the snippet show you the most related part of the page in relation with your search. It would be great to make the same with this plugin :-) !!
11. Rob | February 16th, 2008 at 9:12 am
Kinda: The basic difference is that the snippet strips out anything but plain text but the excerpt tries to behave like the WordPress excerpt.
Your suggestion is an interesting one. I think it would be possible to implement but not easy. I’ll bear it in mind. Thanks.
12. Kinda | February 16th, 2008 at 9:59 am
Thank you for the difference :).
Your plugin is very good. With “targeted snippets” it woud be GREAT ;-) !
Perhaps taking the 2 most important words and targeted them :-? (you also could give us the possibility to transform the words targeted this : like strong word strong, but this is just to improve after, after,… ;-)
Have a nice we :) ! And thank you again for your plugin !!
13. Mark | February 16th, 2008 at 12:25 pm
Thanks Rob! I absolutely love this plugin!!! I got most of it to work except that when you click on the excerpt it just goes to the post instead of to the category.
{link}{excerpt}…
Where {URL} is I tried putting {catlinks} and that did not work either… I also tried putting the {catlinks} after the {excerpt} and that didn’t work either. Is this wrong? I can’t figure it out… :-( This is where I am trying to do this http://stevehowellmoviestv.com under the TV, Movies, Remembering at the bottom of the page.
14. Mark | February 16th, 2008 at 12:25 pm
{link}<a href="{url}">{excerpt}...</a>15. Rob | February 16th, 2008 at 3:45 pm
Mark: There is a way but it is going to be messier than I’d like.
You need a different output template for each category but that’s OK since you are already calling recent_posts three times, i.e.:
You have to pass the output template as a parameter along with the
i.e.
(note the ‘&’ … and please ignore the four extra slashes!)
Give that a try! It would have been a little easier if you were using pretty permalinks I think.
16. Mark | February 16th, 2008 at 11:15 pm
Thank you so much for your help!!!!!! It works great!
17. Yedidia | February 18th, 2008 at 9:11 pm
I upgraded to WP 2.3.3 and so I had to upgrade the “recent posts” plugin
but the recent post displayed are not recent at all…
also… any chance my img in the wordpress excerpt could show as a result of “recent post” and no text at all?
18. Rob | February 19th, 2008 at 1:13 am
Yedidia: Can you explain some more what you mean in your first sentence?
You could perhaps show the image and no text by using some clever CSS…
19. Deuce | February 26th, 2008 at 10:50 pm
Had anyone figured out how to output a custom field (thumb image) with the recent posts plugin? I just need thumb images to show with my recent posts.
Maybe someone has covered it, but I can’t seem to find it on here.
Thanks! Very Awesome Plugin.
20. Rob | February 27th, 2008 at 9:48 am
Deuce: You can output the text contained in a custom field using the output template tag {custom:name_of_field}. If you had a field called ‘thumb’ containing the url of the thumbnail image you would try something like:
I hope that helps.
21. robin | February 29th, 2008 at 2:17 pm
This is an excellent plugin and I love the admin interface.
But I’m finding that no matter how I tweak the settings, I get a lot of “None Found.”
In the absence of going back and making a lot of changes to old content, I think what I really need is a way to match based on tags and categories excluding title and content. Is there a way to tweak the plugin to exclude this or should I be looking at another plugin?
Sorry if I sound like I’m proposing to uglify such a beautiful thing.
22. Rob | February 29th, 2008 at 6:09 pm
robin: Thanks for the positive comments. I am surprised you are getting a lot of ‘not found’ — I virtually never get them unless I constrain the other parameters too tightly. I wonder if there’s a bug or configuration issue?
The next version has the option to judge similarity by any combination of content, title, or tag and should be out ’soon’.
23. S | March 1st, 2008 at 2:15 am
Hmmm… I am having the same problem as Yedidia. I just upraded my blog to WP 2.3.3 and now the recent posts seem to be from a couple years ago.
I am using this code to display:
<?php recent_posts('limit=10&included_cats=3&output_template=<b>• {link}</b><br>'); ?>24. Rob | March 1st, 2008 at 9:51 am
S: Thanks for the report. Can you let me know the versions of PHP and MySQL you are using?
25. S | March 1st, 2008 at 10:05 am
Thanks for your quick feedback: MySQL 4.1.21 and PHP 4.4.4.
Here are the full server details: Apache/1.3.37 (Unix) mod_ssl/2.8.28 OpenSSL/0.9.7a mod_perl/1.29
tks!
26. Rob | March 1st, 2008 at 10:51 am
S: I thought this might be the problem. MySQL has a bug in version 4.1.21. I have documented it and suggested a workaround on the Recent Posts page under ‘Usage’. If you can convince your host to upgrade MySQL it would be a better solution. Good luck! Let me know if you succeed.
27. Rob | March 1st, 2008 at 2:19 pm
S: I’ve just been reconsidering the workaround mentioned above. If, as in your case, you are using WordPress version 2.3 or higher you can simply drop the ‘DISTINCT’ in the SQL query. Get back to me if you need more guidance on how to do that.
28. S | March 1st, 2008 at 3:48 pm
Hi, thanks for your comment. I would like to try your second idea of removing ‘DISTINCT’. I’m not sure what to do though. I found this line of code and commented it out, but it seems not to work correctly:
$sql = "SELECT DISTINCT " . $needed_fields. " FROM $wpdb->posts ";Pls let me know exactly what I should delete.
29. Rob | March 1st, 2008 at 5:20 pm
S: You have found the right line! All you need to do is remove the word ‘DISTINCT’, i.e.
Please let me know if it turns out OK.
30. S | March 1st, 2008 at 8:04 pm
Yup!! it works very well :) Thank you!
One more question: after I have my mysql upgraded, is it ok to still have “DISTINCT” removed or is it best to add it back? Does the removal place additional stress/strain onm the server for caching?
31. Rob | March 1st, 2008 at 8:26 pm
S: I’m glad it works … you can forget about DISTINCT for good. I realised that it wasn’t needed in the code for WP 2.3+ and have removed it from the next version. I just had to make sure there was a workaround in place for earlier versions of WP.
(There is no effect on caching. If anything the server has to do less work as the query is simpler.)
32. craig | March 4th, 2008 at 3:13 pm
Howdy,
I’m interesting in pulling up the IP address of the commenter, so that I can display their country flag next to their name.
Ideas on how I might be able to do that?
33. craig | March 4th, 2008 at 3:47 pm
Ahhh — nevermind Rob, I’ve got it.
34. Rob | March 4th, 2008 at 3:57 pm
craig: I’m glad you worked it out! I’ll incorporate the tag in the next version. Thanks.
35. Shanx | March 12th, 2008 at 2:23 am
Hi. I am using the Recent Posts plugin, and would like to list the posts in alphabetical order, not by date.
Questions:
1. Is there any option to overwrite this default date ordering? (I know “Recent” means recent, but I like your plugin and want to use it to list other stuff too).
2. Is there any trick to show the listing in two columns instead of one? I can do this with two float:left spans, and call the Recent Posts with two template tags (i.e., twice), but don’t quite know how to make sure that the titles that are displayed in the first call are NOT repeated in the second.
Thanks!
36. Rob | March 12th, 2008 at 9:41 am
Shanx:
1. Do you mean to select the (say) 10 most recent posts and then display them in alphabetic order? If so there’s no way to do that … but people keep asking for a similar behaviour so I might look into it.
2. You may be looking for the skip setting. You could then list the first 5 with skip = 0 and the next 5 with skip = 5.
37. AJ | March 17th, 2008 at 4:47 pm
Hi, I keep getting this error in my dashboard using Similar Posts:
Warning: Missing argument 1 for admin_subpages() in /home/slash/public_html/wp-content/plugins/post-plugin-library/admin-subpages.php on line 17
And this on my posts:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't worth it__' ))) + (2.44285714286 * (MATCH (`content`) AGAINST ( " managed pray' at line 1]
SELECT *, ((0.36 * (MATCH (`title`) AGAINST ( ‘cockroach hunting isn’t worth it__’ ))) + (2.44285714286 * (MATCH (`content`) AGAINST ( ” managed prayer cockroach food level rune trip mith takes time money skilling higher-medium levels nope lower worth cosmic minutes make” ))) ) as score FROM `blog_similar_posts` LEFT JOIN `blog_posts` ON `pID` = `ID` WHERE (MATCH (`title`) AGAINST ( ‘cockroach hunting isn’t worth it__’ ) OR MATCH (`content`) AGAINST ( ” managed prayer cockroach food level rune trip mith takes time money skilling higher-medium levels nope lower worth cosmic minutes make” )) AND post_status != ‘future’ AND post_status=’publish’ AND post_type=’post’ AND ID != 34 AND post_password =” ORDER BY score DESC LIMIT 0, 5
None Found
I’m using Wordpress 2.3.3 and Similar Posts plugin 2.5b1
38. Rob | March 17th, 2008 at 5:50 pm
AJ: Try v 2.5 b2 which I have just uploaded. Thanks for the bug report. It should fix the second problem. I am working on the first.
39. Rob | March 17th, 2008 at 6:23 pm
Version 2.5 b3 posted — fixes the admin options pages mess (I hope — feedback would be good!)
40. CWF Game Cast | March 24th, 2008 at 5:23 am
I have encountered an error with this plugin and WP 2.5 RC1. I am using 2.5 b5 of this plugin, updated via the automatic updater in WP 2.5 RC1.
The error message I receive is
How do I rectify that? My blog is located at http://wargamingforums.com
41. CWF Game Cast | March 24th, 2008 at 5:34 am
I must apologize for the double post. The reason for this 2nd post is that I fixed the problem. 2.5 b5 of this plugin doesn’t work with WP 2.5 RC1, at least not for me.
So, I reverted to 2.5 b4 downloaded directly from this site. I then uploaded both the plugin and the library folders into my plugins folder and that did the trick.
Don’t know how WP got 2.5 b5 of this plugin from automatic install but it may be worth looking into. Once again sorry for the double post.
42. Rob | March 24th, 2008 at 8:55 am
CWF: My apologies! I am having trouble with the automatic download function. You would need to go to the wordpress.org download site and also download the Post-Plugin Library as well as the Similar Posts plugin. In fact if you could try that for me I would be very grateful.
43. Tanguillo | March 24th, 2008 at 5:25 pm
Rob, I have a problem. I just download the wordpress.org version of the plugin, installed (I delete the older one first) and it shows me the message: “Please install the Post Plugin Library”. I don’t delete that library, is still in the root of plugins.
I try do deactivate, and activate the plugin, show no errors, but the message is still there.
Where should I look up?
44. Rob | March 24th, 2008 at 5:37 pm
Tanguillo: Can you follow these links to download the latest versions of both Similar Posts and the Post Plugin Library and then let me know how things stand and we can work out from there what the problem is.
45. CWF Game Cast | March 24th, 2008 at 7:13 pm
Which version is the most current of Similar Posts? Is it 2.5 b5 or 2.5 b4? This site says 2.5 b4 is the most current. But, my dashboard of my WP blog says 2.5 b5 is the most current.
46. CWF Game Cast | March 24th, 2008 at 7:14 pm
Which version is the most current of Similar Posts? Is it 2.5 b7 or 2.5 b4? This site says 2.5 b4 is the most current. But, my dashboard of my WP blog says 2.5 b7 is the most current.
47. Stefan | March 24th, 2008 at 8:52 pm
2.5b5 didn’t work on my WP 2.3.3 so I switched back to 2.5b4.
48. Rob | March 24th, 2008 at 9:12 pm
CWF: The versions on this site are packaged differently — use them if you wish — but the versions on the wordpress directory site are newer and (hopefully) will be the ones that will be developed. There is very little difference in functionality as yet. I am having some difficulty with the directory site though — check out my recent blog posts.
49. Rob | March 24th, 2008 at 9:14 pm
Stefan: How did 2.5 b5 not work for you? Check out my recent blog posts for some information that might be helpful.
50. Stefan | March 24th, 2008 at 9:33 pm
Hi Rob, I’ve got some kind of php error: “line 44 in blabla php” with 2.5b5 but I’ll check out the latest version. By the way: Do you have 2 posts each with about 300 coments for the same plugin? A little confusing. :-)
51. CWF Game Cast | March 24th, 2008 at 9:51 pm
Rob: Thanks for your help. That is rather confusing to have the versions packaged differently. Maybe you’ll be able to keep them in sync between here and the WP site in the future?
I installed 2.5 b7 from the WP site and all works perfectly. I did it the old manual way but am hoping the automatic updater will work with your plugin soon. I bet a lot of people will use that method when WP 2.5 final is released.
I really appreciate all your help. Many thanks!
52. Stefan | March 24th, 2008 at 9:58 pm
I had to switch Similar Posts 2.5 b7 on and off twice because after first activation SP told me that Post Plugin Library was not installed (but it was, new version). Now it works. Thanks again for your great plugin!
53. Rob | March 24th, 2008 at 10:57 pm
Yes, I’m hoping that the official directory will work out well in the long term. Right now it’s a nightmare because it’s not showing the installation instructions correctly and not properly reporting version numbers for the automatic update. I presume I’ve done something stupid along the way but I really don’t know what it is and so far I have had no response from the site administrator. But here’s hoping …
54. Joe | March 25th, 2008 at 12:41 am
I can’t get {php:code} to work
I put in: {php:sr_getsingle(’2′);} to the template
And all I get in the output is:
{php:sr_getsingle(’2′);} (literal)
Second question, could I do this?
{php:sr_getsingle(’{postid}’);}
Thanks!
55. Rob | March 25th, 2008 at 8:20 am
Joe: First, let me check if you are running version 2.5 of the plugin. Also, if you are, it would help if you made a bug report through the plugin’s admin page because it would tell me a lot about your selected options etc.
Does
{php:echo 'hello';}work?56. Joe | March 25th, 2008 at 1:23 pm
Alright cool I got 2.5 and it works, but I need to pass the ID of the post being displayed to my function, if i use “get_the_id()” it just uses the ID of the main post (the one that’s in the “loop” above the recent_posts() function)
How can I pass the ID of the post being called to display?
I tried this:
{php:sr_getsingle({postid});}
but the first “}” closes it and so it ends up just outputting “);}”
Don’t worry about sr_getsingle() that function works… just help me pass the ID to it :)
57. Rob | March 25th, 2008 at 1:31 pm
Joe: The {php} tag ‘knows’ the
$resultobject which contains the values of all the fields from wp_posts so you should be able to use$result->ID, i.e.,{php:sr_getsingle($result->ID);}.Good luck!
58. Joe | March 25th, 2008 at 1:48 pm
Well I want this to be a CSS class
So I’m doing it like this:
where xx = whatever i need to do to pass the ID
Can I open code tags up in there? I don’t think I can….?
59. Rob | March 25th, 2008 at 1:58 pm
Joe: Sorry, you lost me there…
60. Joe | March 25th, 2008 at 2:01 pm
Oh sorry, the HTML code got knocked out
<span class="rating r{php:sr_getsingle(xx);}"></span>So the function sr_getsingle(postid) returns a number that I use in my CSS to change how something looks.
61. Rob | March 25th, 2008 at 2:08 pm
Joe: The use of
$result->IDshould still work62. Sue | March 28th, 2008 at 12:41 am
Hi Rob!
I have installed the similar posts plug in and am hoping there is a way to present the similar posts on a line rahter than a vertical list, such as
Similar Posts: and the following centered:
[Post 1 ~ Post 2 ~ Post 3
Post 4 ~ Post 5]
Is there a way to accomplish that?
Many thanks,
Sue
63. joe | March 28th, 2008 at 2:43 am
hell yea dude your advice worked for me props, mothaf**ka
64. Rob | March 28th, 2008 at 10:02 am
Sue: Try this…
Set output template to: ‘ ~ {link}’
Set text before to ‘['
Set text after to ']‘
Set text to trim at start to ‘ ~ ‘
That should give you the output you want but you might have to play with your templates CSS styles to
a) get it centred
b) ensure the links display inline
Good luck!
65. Sue | March 29th, 2008 at 3:27 am
Thank you Rob. Indeed, I think the css coding may be the tricky part. I will give it a while.
many thanks,
Sue
66. vladimir | March 29th, 2008 at 8:02 pm
One of the best plugins around, hats down.
Vladimir
67. Bierflesje | March 30th, 2008 at 6:49 pm
Hi, thanx for the plugin.
After upgrading to WP2.5 and your latest plugins the similartherms custom field isn’t there anymore.
Although similarterms is working, i cant create or edit the terms.
How can i get it back?
68. Rob | March 30th, 2008 at 9:20 pm
Bierflesje: I’m afraid they are gone! Version 2.5 uses its own table rather than indexing wp_posts. I think the need for extra keywords has diminished with the new facility to match by tags.
If you want to remove the plugin (use the option from the Similar Posts settings page to remove the table too) you can downgrade to an earlier version.
69. Ivars | March 31st, 2008 at 7:41 pm
If we have for example 20 most frequent words of post content, why not to use it to upgrade post tags list like as in Headspace?
70. Rob | March 31st, 2008 at 9:39 pm
Ivars: Are you thinking of META keywords? It would certainly be possible to do that kind of thing.
A project I’ve been more interested in has been automatic tagging of blog posts or, at least, tag suggestion. There’s an enormous and growing literature on the subject and I have a few algortihms in reserve to apply to Similar Posts but I have realised that while extracting key words is a good basis for comparing similarity it doesn’t do a very good job of tagging because tags, to be most useful, have to add information and extracted keywords can never escape from the universe of the actual text. There are a number of approaches I’m playing with but they tend to be handicapped by PHP’s lack of mathematical libraries. Python is dripping with them but PHP not so much.
Sorry to go off topic. Are you suggesting the addition to Similar Posts of the option to add META tags to the head?
71. Michael Lee | April 1st, 2008 at 4:20 pm
Thank you again for building this - it is immensely useful to me.
The “Random Posts” plugin is throwing an error in my apache logs. The error is as follows:
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND post_password ='' ORDER BY RAND() LIMIT 0, 3' at line 1 for query SELECT * FROM wp_posts WHERE post_status != 'future' AND post_status='publish' AND post_type='post' AND ID != AND post_password ='' ORDER BY RAND() LIMIT 0, 3 made by executeIt’s non-fatal, the plugin works fine, but I think the error is caused by an extra space in line 88 of random-posts.php:
$sql .= " ORDER BY RAND() LIMIT $limit";72. Michael Lee | April 1st, 2008 at 4:25 pm
nope, guess not. Took the space out, still getting the error.
73. Rob | April 1st, 2008 at 6:18 pm
Michael Lee: The problem is that you are asking it to exclude the current post from the random listing but for some reason the plugin can’t ascertain what the current post is. I have changed the code so the plugin doesn’t explode if it encounters this condition. I’ll post the update soon but in the meantime just try unsetting the option to omit the current post.
74. GMATPrep | April 2nd, 2008 at 4:42 am
Just upgraded to latest version to support WP2.5. I get “None Found” string instead of similar posts.
Please guide
75. GMATPrep | April 2nd, 2008 at 5:09 am
We get this error while activating the plugin
Fatal error: Cannot redeclare similar_posts() (previously declared in //public_html/xxx/blog/wp-content/plugins/similar-posts/similar-posts.php:33) in /home2/scorech/public_html/xxxt/blog/wp-content/plugins/similar-posts/similar-posts.php on line 33
76. Rob | April 2nd, 2008 at 9:33 am
GMATPrep: This is a problem I am still trying to understand. If you have access to the Similar Posts settings screens please submit a bug report to help me track down a proper solution. In the meantime the FAQ on the Similar Posts page should be helpful.
77. camu | April 2nd, 2008 at 4:35 pm
Hi there, thank you for this great piece of code. I upgraded to latest version. Maybe I have too many articles (700?) for this plugin to complete the reindexing. After a couple of seconds I just get a blank page. If I check the database, wp_similar_posts is there, but it contains around 200 rows. I think it is a problem related to some limit in PHP execution times, set by my provider. Is there a way to reindex my articles directlty through a mysql query? Moreover, I see that also similar_terms custom field, is not defined for all my articles anymore. Thanks, camu.
78. Rob | April 2nd, 2008 at 6:06 pm
camu: Let me start with the last point. The plugin now uses its own database table rather than using custom fields. It allows more flexibility and was needed to make tag searching possible. If you edited the custom field to sharpen up the matching you should be able to do a similar thing with the WordPress post tagging system.
700 articles doesn’t seem that much different than my own blog so I’m surprised that re-indexing isn’t working. Using the extended character option and/or using stemming does make quite a difference to the time taken though. There isn’t a simple SQL query to do the job. Try using the PHP code
ini_get(max_execution_time);to see what the current time limit is. The default is 30s. I doubt your host will have restricted the execution time to just a few seconds.It is more likely that you have uncovered a bug which is causing the indexing to silently abort. I hope you’ll be able to help me track it down. It would be helpful if you could send me a bug report from the settings page as it lets me know version information etc. It would also be useful to know whether you are running in safe mode.
79. camu | April 2nd, 2008 at 6:45 pm
Thanks Rob, I’ve just filed a bug ticket, but I don’t know if you received it, since I keep getting this error message:
Warning: Invalid argument supplied for foreach() in /websites/LinuxPackage04/rm/ar/sh/rmarsh.com/public_html/wp-content/themes/Blix/bug.php on line 112
Sure I can help you fixing the bug, if any! Maybe there is a conflict with some of my plugins?
80. jcwinnie | April 2nd, 2008 at 11:10 pm
Was working fine until most recent automatic upgrade. Now Similar Post Feeds provides a list but Similar Post shows “None Found”.
My guess is that I need to re-index something.
81. Rob | April 2nd, 2008 at 11:38 pm
jcwinnie: If you have access to the Similar Posts settings screens please submit a bug report to help me track down a proper solution. In the meantime the FAQ on the Similar Posts page should be helpful.
Thanks!
82. online business blogger | April 3rd, 2008 at 2:15 pm
Hi
These plugins are briliant, you have certainnly spent a lot of time and giving a lot of thought into each and every one of them, excellent.
There is one question I have, I’m using the similar post plugin and to pull posts from several categories. This is great for human visitor but not so good for silo structures.
What is required is the ‘nofollow” tag after the URL’s (i.e. post titles) so that the SE spiders do not follow the links and mess up the silo structure.
I guess I could restrict the categories on a post-by-post basis, but I think an option to enable/disable “nofollow” would be ideal.
83. Rob | April 3rd, 2008 at 5:40 pm
online business blogger: All you have to do is construct the output template you want rather than using the shorthand {link}, e.g.:
Does that help?
84. online business blogger | April 4th, 2008 at 1:52 am
cool! that did the trick.
now I’ll go and play withe the randon post plugin
85. Уолтер Мондейл | April 6th, 2008 at 3:29 am
проверка
86. Erick | April 6th, 2008 at 5:28 am
Please clearly indicate which template tags such as {link} are possible. Where is the link where all of these options are listed?
87. Rob | April 6th, 2008 at 10:29 am
Erick: The output template tags are all listed on this page above.
88. Chris Masse | April 8th, 2008 at 5:00 pm
Hi,
Thanks for this great plugin. FYI, there is an incompatibility between “Similar Posts” and “Admin Drop Down Menu”. The sub-menu of “Similar Posts” does not appear.
Thanks for listening.
Chris Masse
89. Rob | April 8th, 2008 at 6:18 pm
Chris Masse: Thanks for the kind words and for letting me know about the incompatibility. Do you mean the plugin by Ozh? Or the version by Yellow Swordfish? At present I have both (not at the same time!) working alongside Similar Posts with no issues. However, I am having a problem with Lighter Admin Drop Menu from corpodibacco which I am working on.
Could you send me the details of plugin and versions and which browser you are using?
90. Chris Masse | April 8th, 2008 at 9:01 pm
I meant “Admin Drop Down Menu” by by Ozh. [I do also use “WordPress Admin Bar”, by the way.’
-
I was not saying that “Similar Posts” does not work with your plugin. I’m saying that the sub-menu of “Similar Posts” does not appear. Only the first option page in “Settings” appear, not the other ones.
Thanks,
Chris Masse
91. Rob | April 8th, 2008 at 9:15 pm
Chris Masse: Ozh’s menu doesn’t interfere with the Similar Posts settings submenus on my systems. Can you give me some more information about your own system and browser so that I can try and see if I can duplicate the problem you are having. Thanks.
92. Kevin Goldman | April 8th, 2008 at 10:56 pm
Can this module also add the “current_page_item” class to the item that is currently being viewed? I bet it can. I just can’t find where to set this up.
Any advice would be greatly appreciated. Thanks,
93. Rob | April 8th, 2008 at 11:17 pm
Kevin Goldman: I’m not sure what would constitute the ‘item being currently viewed’ in the context of the output from these plugins… I guess it depends which plugin and how you are using it. It sounds like you have a very particular use in mind. If you fill me in a bit I might be able to see what you are hoping for. Some kind of menu?
94. Kevin Goldman | April 8th, 2008 at 11:31 pm
Hi Rob, thanks for the incredibly quick reply. Let me try to explain. WordPress will add the “current_page_item” class to menu items if the menu item matches the page you are viewing.
For example: if I’m on the Contact Us page here: http://breathyogandhealing.com/blog/contact-us/ then the “Contact Us” main menu item is white since it’s tag has the “current_page_item” class applied to it. In my CSS I make the “current_page_item” background white.
Another example, I’m using NAVT Lists for the side menu of my site. If you view this page http://breathyogandhealing.com/blog/tai-chi/ you’ll see that the side menu for Tai Chi is also highlighted because it’s tag uses the “current_page_item”.
So.. : ) I’d love to find a way that the recent posts menu items will behave the same way. For example, if I’m on this page http://breathyogandhealing.com/blog/phoenix-arizona-heat/ I’d like the that shows the “Phoenix Arizona He…” menu item to have the “current_page_item” class assigned to it.
I really hope this makes sense. And again, thanks for the quick feedback. BTW - do you accept donations? I’d be more than happy to send one view paypal, etc.
95. Rob | April 9th, 2008 at 7:47 am
Kevin: That all makes perfect sense … I just hadn’t thought of anyone using the plugin in this way. Most people use it to list recent posts rather than pages. It should be relatively easy for me to mark the current list item in some way. I’m looking into it.
Since you ask there’s a donations link on the wordpress.org plugin site where Recent Posts is hosted.
96. Rob | April 9th, 2008 at 3:38 pm
Kevin: After a little reflection I realise you can do what you want with the {php} output template tag.
This will apply a class when the current post ID matches the ID of the item in the list.
At present there is the option to include or exclude pages but you always get posts. Would it be useful to have the option to only show pages and not posts?
97. Kevin Goldman | April 9th, 2008 at 4:06 pm
HI Rob, thanks so much. I thought it would be possible with the {php} tag. But, I may have something wrong in my output template since this doesn’t seem to execute the PHP code.
This is what I have in my output template:
<li {php:if ($result->ID === $post->ID) echo "class=\"current-item\"";}>{link:maxlength:trim}</li>The result here http://breathyogandhealing.com/blog/benifits-of-hophup-yoga2/ shows the code not the output.
Sorry in advance for all the questions : | I might as well stick with it here since it looks like this is very close to a resolution. Thanks again.
98. Kevin Goldman | April 9th, 2008 at 4:53 pm
Hi Rob, I had to remove incorrect output at the link above for the time being. But I uploaded this screen grab so you can see what the problematic output was:
http://breathyogandhealing.com/hohup-sidebar.png
99. Rob | April 9th, 2008 at 5:53 pm
Kevin: Grab the latest version … 2.5b16. I found a small error with ‘->’ in {php}.
Any response about the page only option?
100. thiefhunter | April 9th, 2008 at 10:07 pm
Excellent plugin, thank you. Works perfectly, and I learned so much just reading your customization page.
101. Shiv | April 12th, 2008 at 9:38 am
Hi there!
Firstly thanks for the great plugin, it’s perfect for my needs :) :)
Unfortunately since I upgraded to the latest version it stopped working :( The widget works fine but I don’t use that, what I use is the special tag in a post to show the recent posts list on my front page, however since upgrading te special tag doesn’t seem to be getting replaced anymore :( (If you view-source on the page you can still see the tag in the HTML just after the front page post)
Any ideas what it could be? I’ve tried deactivating and reactivating but that hasn’t helped, I’ve also checked that “Replace special tags in content” in the options is set to “yes”.
Any help would be much appreciated!!
~Shiv
102. Rob | April 12th, 2008 at 10:31 am
Shiv: You are right. The Similar Posts tag was being replaced but not the one for Recent Posts. I have fixed the problem and will be uploading a new beta version shortly.
103. Christian Otto | April 12th, 2008 at 12:04 pm
Hi Rob,
I really like your plugin. Even though it´s quite powerful, I could handle it pretty well even as a novice in all things HTML. But I still have one problem with the gravatar tag and I hope you can help. I use it the tag with these parameters:
{gravatar:33:G:http://www.christianotto.de/blog/wp-content/plugins/wp-gravatar/nogravatar.bmp}
But when the commenter has no gravatar, not my own default image is shown but a default provided by Gravatar.com. Did I make a mistake?
Thanks,
Christian Otto
104. Rob | April 12th, 2008 at 2:27 pm
Christian Otto: Can I convince you it was a deliberate mistake? … I thought not!
I had a couple of stray characters messing things up. I will post an update (2.5b19) of the Post-Plugin Library in a few minutes.
105. [/root.] | April 12th, 2008 at 2:49 pm
Thanks for the plugin. I have one question. I’m trying to display the similar post but the first one should have li class=”first” parameter.
text
text
How can I implement this code into plugin?
106. Christian Otto | April 12th, 2008 at 3:07 pm
Hi Rob,
I instantly upgraded both the Post-Plugin Library and Recent Comments to version 2.5b19 but still the wrong default images are shown. Maybe it´s something else? *scratches head*
107. Rob | April 12th, 2008 at 4:30 pm
[/root]: I think you can do what you want with the {php} output template tag.
If your template was:
make it into:
It checks if a variable ($xwq should be unlikely enough) has been given a value and if not adds the class. It then gives the variable a value so that the subsequent items in the list don’t get the class.
Give it a try.
108. Rob | April 12th, 2008 at 4:41 pm
Christian Otto: I’ve uploaded version 2.5b20 of the Post-Plugin Library which (I hope) fixes the problem.
109. schreibstift | April 13th, 2008 at 10:37 am
Thanks for the great Plugin!
It is possible to omit author comments.
But how can I exclude comments of all wordpress users? I only want to show guest comments.
110. Thomas | April 13th, 2008 at 11:11 am
Hi,
thanks for this fantastic plugin. I got one question.
How would I pass parameters so that only pages are displayed and no posts.
Thanks Thomas
111. Rob | April 13th, 2008 at 11:30 am
schreibstift: You can’t do that at present. I’m not sure what you mean … do you mean the exact opposite of ‘omit author comments’? If so it would be easy for