• I’ve read tutorials about showing custom post type with the same category but it seems that all I get was the same posts from the main loop. I want to display custom post type named ‘content_block’ (it’s from the Custom Post Widget) in the sidebar. Here’s my code:

    $custom_event = new WP_Query(array(‘post_type’ => ‘content_block’, ‘posts_per_page’ =>5));
    while ($custom_event->have_posts() ): $custom_event->the_post();
    echo the_title();
    echo ‘</br>’;
    echo the_content();
    echo ‘</br>’;

    endwhile;

    It doesn’t display the custom post type content_block but instead the post from the main loop (which is another custom post type)
    Please help me. ??

    Thank you in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter Blizzie

    (@lizzbernardo)

    Maybe it is conflicting with this:

    add_filter( ‘pre_get_posts’, ‘my_get_posts’ );

    function my_get_posts( $query ) {
    if ( is_home() )
    $query->set( ‘post_type’, array( ‘memorandum’ ) );

    return $query;
    }

    I have that code in the function.php

    Please reply asap ??

Viewing 1 replies (of 1 total)
  • The topic ‘Show custom post type with the same category’ is closed to new replies.