• Resolved Webmaster_crawl

    (@webkingashu)


    I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrive the post and display them.

    <?php
    // Counter
    $post_count = 1;
    
    // Query
    $gp_query_args = array(
        'post_type'         => 'event',
    
        //EXCLUDE Events try by me
        'post__not_in' => array('1646'),
        // exclude event try code block ends
    
        'meta_key'          => 'gp_event_date',
        'meta_value'        => date('Y/m/d'),
        'meta_compare'      => '>=',
        'orderby'           => 'meta_value',
        'order'             => 'ASC',
        'posts_per_page'    => -1
    
    );
    $gp_query = NULL;
    $gp_query = new WP_Query($gp_query_args);

    I want to exclude certain events (post of custom post type, from loop), and as you can see i tried using ‘post__not_in’ => array(‘1646’), where 1646 is the post id i see when i edit the custom post . So i guess this is universal post id, not custom post type specific id. But No Matter, the post is not being excluded 🙁

    Am i doing wrong??

    Edit1:

    I found a repository on github ( https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php ) that is exactly similar to my theme structure. I dont know the theme name, so i’m not sure whether that’s the same theme on the site i’m working over.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cannot exclude particular post from loop of custom post type’ is closed to new replies.