-
Author
-
March 27, 2015 at 15:14 #51815dolphspeed99Participant
Hello,
I need to use related posts to show posts that I manually select. Is there a way I can do this by modifying your related posts code? I don’t want to use another plugin for this, I like your code and want to stick with it. Another option that could work instead of manually select is to choose the related posts based on tags, so if I assign the tag “related-endomorph” to a post, I want the related posts to show posts with the same exact tag, “related-endomorph” and, if there aren’t a minimum of 3 articles to display, the code could look for other articles based on category/title or whatever algorithm you are using.
I also know this isn’t subject to support as it is customization, but I would really appreciate some help, especially that I setup all the theme by myself without asking for help, and it could also be a very nice feature to implement in the following updates.
Thank you!
March 30, 2015 at 15:03 #52222AndreiModeratorHi,
The file you need to modify is the following ( you should copy it in your child theme, and make the modifications there ) : wp-content/themes/kleo/page-parts/posts-related.php
You will see that at the beginning of the file there are some query args which you can modify to target your related posts. A few details about how you can modify those args can be found in the following page: https://codex.wordpress.org/Class_Reference/WP_Query
Hope this information helps you achieve what you need.
CheersHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMarch 30, 2015 at 18:41 #52246dolphspeed99ParticipantUnderstood, thank you so much for your help, I really appreciate it.
August 20, 2015 at 18:53 #73958siloynetParticipantI would also like to change the related posts from categories to tags. I check the wordpress codex page, but i am still confused.
Could anyone please tell/guide me the change that need to be done
COPY CODE//logic for blog posts if (is_singular('post')) { //related text $related_text = __("Related Articles", "kleo_framework"); $categories = get_the_category($post->ID); if (!empty($categories)) { $category_ids = array(); foreach ($categories as $rcat) { $category_ids[] = $rcat->term_id; } $args['category__in'] = $category_ids; } }
Thanks
August 27, 2015 at 19:04 #74882AndreiModeratorInstead of : $categories = get_the_category($post->ID); change it with $categories = array(‘YOUR_CATEGORY_ID’);
Cheers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMarch 21, 2016 at 19:25 #112035hoopsParticipanthi! also want to display related articles by TAGS.
what changes are needed in wp-content/themes/kleo/page-parts/posts-related.php ?
thanks!
March 22, 2016 at 16:44 #112207AndreiModeratorHi @hoops, please check my earlier posts from this topic, you can find a link to the WP Query documentation where you have example for filtering posts by tags.
Cheers
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.