开发者 | cfischer83 |
---|---|
更新时间 | 2024年11月16日 05:30 |
PHP版本: | 4.0.0 及以上 |
WordPress版本: | 6.7 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
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):
<?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.
similar-posts-ontology
to the /wp-content/plugins/
directoryThere are two aspects to it. First, it finds all similarly tagged, categorized, and otherwise taxonomically created content on your site, then sorts it by what has the most similarities. Second, if there is a tie between two posts it will give the edge to the newest content, or content posted closer to the time your current post was posted, depending how you configure it.
Ontology is the study of the nature of 'being'. This plugin uses the ontological philosophy of determining an entities placement within its own 'type' by studying the entities relationships.
You can use this in two ways. Either by calling pk_related_return() in your theme or by placing the widget on your site. If you are using the widget, remember that it only works on any "single" page (where is_single() would return true). The pk_related_return() can theoretically work anywhere as long as you provide a proper post ID. Try var_dump() with pk_related_return() and look at the description for proper usage of this function.
This issue may be your taxonomies. The content for which you're trying to find related content needs to have tags, categories, and/or custom taxonomies. Also, to properly find your content, tags/categories/taxonomies must be used on the related content as well. The more you intentionally use your tags and categories, the better your results set will be.