Do you have a solid category structure on your blog? If so, you probably don't need a "Related Posts" section at all - you can just display the latest posts in the same category.
In this post, we’ll introduce the “More in this category” section, an alternative to “Related Posts” (which we’ve covered before).
If you organize your posts well into categories, you may find it useful to have a list of posts within a post category.
"Related Posts" isn't always the answer: If posts on your site areseparatedby category, then a "Related Posts" section may "break" that separation.
For example, if you have a blog about a different occupational group, you cannot show news about the textile industry as "Related News" under a post about informatics. Many recent posts in the same category would be more relevant, right?
As you may have guessed, it is much easier to list the latest posts in a post category than to display related posts based on post tags. We just need to get the category of the post and list the many posts in that category, excluding the post the visitor just read. The parameters we can pass in theget_posts()
function contain everything we need.
ID ); $first_cat = $categories[0]->cat_ID; // Let's start the $output by displaying the title and opening the
Sorry, this category has just one post and you just read it!
'; } // Let's close theFinish! You can include this function in yourfunctions.phpfile (or save it as a separate plugin) and echo it (like) inanywhere in the single.phpfile.
Yes, the content may be "king", but a lonely king is a weak king, and people may not respect that "king".
Do you think there are more page elements that can help "The King"? Please leave your comments below - it's always important for you to share your thoughts with us!
The above is the detailed content of Quick Tip: After Content - More Content in the Same Category. For more information, please follow other related articles on the PHP Chinese website!