跳到内容

Similar Posts Ontology

v2.1

cfischer83 · 2015年1月11日 上架

Show a list of related posts that are similar to another post.

正在使用
50+
评分
5.0 / 5
累计下载
3,955
最近更新
2025年12月16日
2 条评价需要 WordPress 4.0.0+已测试到 6.9.12

贡献者

截图

You can define how your widget looks from the widget admin/edit screen.
You can define how your widget looks from the widget admin/edit screen.
You can have it output as a simple list like other, typical side-bar widgets.
You can have it output as a simple list like other, typical side-bar widgets.
Or you can add fields and your own styles to really make it stand out (this example is found at www.bluecrayon.net)
Or you can add fields and your own styles to really make it stand out (this example is found at www.bluecrayon.net)

Does your website utilize categories and tags? Does it use custom taxonomies? If so, this plugin will find similar content
based on all your taxonomies. There are two ways to show related posts within your page.

  • The first way to show related content on your post is to use the widget provided. This only works when is_single() is true
  • The second way to show similar content on your site is to use the pk_related_return($post->ID); function which can be
    called programmatically anywhere you wish!

The Widget included with this plugin gives you the option to limit the amount of posts; it allows you to determine which
fields to show: Featured Image, Author, Date, and Excerpt (Title is required); it allows you to determine which
variant of the featured image to show: thumbnail, medium, large, or full. As of version 2.0, you can now decide whether the
‘similar posts’ sorting prefers posts that are newer or posts that were created closer to the date of the post you’re
viewing.

If you find the Widget doesn’t meet your needs or is too limiting, you can call the functionality programmatically using
this function:

pk_related_return($post->ID, $args);

Where $post->ID is the ID of the post for which you are wanting to show related articles.

The $args parameter is an array with the following values available to you (more coming soon):

  • posts_per_page (int defaults to 5)
  • thumbnail_size (string consisting of one of these values: “thumbnail”, “medium”, “large”, “full”. Defaults to thumbnail).
  • sort_prefer (string consisting of one of these values: “newest”, “closest”. Defaults to newest).

An example might be:

<?php
$args = array (
    'posts_per_page' => 6,
    'thumbnail_size' => 'medium',
    'sort_prefer' => 'closest'
);

The return value of pk_related_return is an array of objects that includes most of the fields within WordPress’s posts
table plus permalink and featured image.

Future Additions:

Allow the user to specify only certain content types (posts, pages, custom) in a request. This would allow you to specify
only products get returned, or only blog posts. This would only be an issue if content types share taxonomies.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums