Answer the question
In order to leave comments, you need to log in
How to display category entries in single.php?
Hello!
There is a custom record type - Directory. It is necessary to display on the page single-catalog.php Records that belong to this product category (Similar products). I can not do it, Google does not help. get_queried_object()->term_id doesn't work.
<?php
global $post;
$args = array(
'numberposts' => 3,
'offset' => 0,
'category' => get_queried_object()->term_id
);
$myposts = get_posts( $args );
foreach ( $myposts as $post ):
setup_postdata( $post );
//...
?>
Answer the question
In order to leave comments, you need to log in
The current category, if it is the default category, can be retrieved via get_the_category() .
But is your custom type bound to category?
Also in the parameters to get_posts() you need to specify the type of your post: 'post_type' => 'catalog', or what type you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question