Related post – Categories WP_Query
-
Hi,
How can I make related posts to be generated by categories and not by tags?
Thanks
Hi,
Why am I not receiving a response to this ticket?
Hi simonghost,
Thanks for reaching to us.
Please try to add the code below in the functions.php file in your child theme.
function woodmart_get_related_posts_args( $post_id ) {
$cats = get_the_category();
$args = array();
if ( $cats ) {
$args = array(
'cat' => $cats[0]->term_id,
'post__not_in' => array( $post_id ),
'showposts' => 12,
'ignore_sticky_posts' => 1
);
}
return $args;
}
Regards,
Hi,
It is also possible through a snippet to exclude two categoryies from the blog page?
Thanks
Hi simonghost,
Thanks for your patience.
The theme doesn’t have a way of excluding categories from the Blog page, but there are some plugins out there that should be able to do this for you.
Here are fews:
https://wordpress.org/plugins/ultimate-category-excluder/
https://wordpress.org/plugins/wonderplugin-exclude-category/
Regards,
Hi simonghost,
Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!
If you have a quick minute we always appreciate a 5-star rating on our theme!
https://themeforest.net/item/woodmart-woocommerce-wordpress-theme/reviews/20264492
Your feedback is the motivation to improve our work and services.
Regards,
The topic ‘Related post – Categories WP_Query’ is closed to new replies.