Category ARchive of wordpress doesn't Show the CPT of metabox

Support MB Custom Post Type Category ARchive of wordpress doesn't Show the CPT of metabox

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #36159
    victoria de clascavictoria de clasca
    Participant

    Hello
    I've created several sites with diferent themes, even the one from wordpress with no other plugins intsalled.

    And I amb seeing that in the Category Archives -categories from wordpress-
    are not displaying the custom post types I created with meta box

    I assigned the category to the post from the CPT and then in the archive of the Category is not displaing

    why are they ot showing?

    thanks

    #36170
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The taxonomy category is assigned to post type post by default, so if you assign category to a CPT, there will be two CPTs connected to that taxonomy. And you will need to modify the query in the archive template to display two (or more) CPTs on the archive page. Just like

    $cpt_ab = new WP_Query( array( 'post_type' => array( 'cpt_a', 'cpt_b' ), 'posts_per_page' => -1 ) );
    while ( $cpt_ab->have_posts() ) : $cpt_ab->the_post();
         the_title();
    endwhile;
    wp_reset_query();

    Read more on the documentation https://developer.wordpress.org/themes/basics/template-hierarchy/
    https://developer.wordpress.org/reference/classes/wp_query/#post-type-parameters

    #36172
    victoria de clascavictoria de clasca
    Participant

    where should I put this code? in every archive page? this is too much work

    is there a way it is automatic with a code in the code snippets?

    thanks you

    #36188
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You need to add the code to the file archive template in the theme/child theme folder, for example archive.php. If you are not familiar with coding, you can create a service request here https://metabox.io/contact/, our development team will help you with an extra fee.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.