9 replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
source | link

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from heresnippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

8 added 6 characters in body
source | link

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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:

Edit1:

I found a [repository on github](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

template-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php

posttype-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/backend/posttypes/posttype-event.php

Thanks

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

template-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php

posttype-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/backend/posttypes/posttype-event.php

Thanks

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

7 deleted 193 characters in body
source | link

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet shown belowsnippet from here in function.php of my theme.

function exclude_single_post_cpt($query) {
if (is_post_type_archive('event') && $query->is_main_query() && !is_admin() ) {
$query->set('post__not_in', array(1646));
}

}

add_action('pre_get_posts', 'exclude_single_post_cpt');

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

template-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php

posttype-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/backend/posttypes/posttype-event.php

Thanks

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet shown below in function.php of my theme.

function exclude_single_post_cpt($query) {
if (is_post_type_archive('event') && $query->is_main_query() && !is_admin() ) {
$query->set('post__not_in', array(1646));
}

}

add_action('pre_get_posts', 'exclude_single_post_cpt');

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

template-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php

posttype-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/backend/posttypes/posttype-event.php

Thanks

I have a custom post type (from a theme installed by previous developer), and here is the code of loop which retrieve 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](links below edit3 ) that is exactly similar to my theme structure. I don't know the theme name, so i'm not sure whether that's the same theme on the site i'm working over.

Edit2

So as per the suggestions below

I did, renamed template-event.php (my template file for showing list of events ) to archive-event.php

And placed the function snippet from here in function.php of my theme.

But i cannot exclude the post with specified ID yet.

Edit3

As asked here is the link of the github repository that is exactly same as my theme.

Github Links:

template-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/template-event.php

posttype-event.php : https://github.com/tiffanytse/breadbyus-wordpress/blob/master/linguini/backend/posttypes/posttype-event.php

Thanks

6 added 308 characters in body
source | link
5 added 564 characters in body
source | link
4 added 2 characters in body
source | link
3 deleted 132 characters in body; edited tags
source | link
2 added 289 characters in body
source | link
1
source | link