• Resolved lobo_

    (@lobo_)


    Hi everybody,

    I am quite new to wordpress and facing a problem which drives me crazy:

    I added a new custom Post type following this guide: https://codex.www.ads-software.com/Post_Types

    So I added the category “einsatz”.

    Additionaly I have a category which is called “einsatz” so that also a normal post and a page can be marked as “einsatz”.

    The new post type works as expected. The only problem is that on my category page https://127.0.0.1/wp/category/einsatze/ the new post type is not displayed. Only “post” types are shown in the list which are tagged as “einsatz”.

    I now tried to add this piece of code to category.php
    $query = new WP_Query( array( 'post_type' => array( 'post', 'einsaetze') ) );

    The result is, that everything which is a post or a einsatz is shown, regardless of the category.

    Also this doesn’t work

    $args = array(
    	'tax_query' => array(
    		'relation' => 'OR',
    		array(
    			'taxonomy' => 'category',
    			'field' => 'slug',
    			'terms' => array( 'einsatze' )
    		),
    		'post_type' => array(
    			'post', 'einsaetze')
    	)
    );
    $query = new WP_Query( $args );

    and there is an additional problem: I need this in a more generic way. So my script has to know which category is called and display everything within thos category.

    I hope somebody can help me.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Types not shown on category archives’ is closed to new replies.