Support

Home Forums Event Espresso Premium Hiding events from the event list

Hiding events from the event list

Posted: March 2, 2018 at 1:23 pm

Viewing 4 reply threads


Khalid Joharji

March 2, 2018 at 1:23 pm

Dears,

I hope this finds you well, three years ago i raised this topic “Hiding events from an event list
in summary, i need to hide some events from the event list while keep the link public for those who have it to register. the trick in the past post worked if i used archived page (pdc-gd.com/eventsss/) but does not work for the page (http://pdc-gd.com/upcoming/) which i can design and make it look nice

the following code worked for the archive page (pdc-gd.com/eventsss/)

.post-type-archive-espresso_events .type-espresso_events.tag-hidden {display: none;}

i tried to edit the code with the following two and none worked for regular pages (http://pdc-gd.com/upcoming/) but no luck

.post-type-article .type-article.tag-hidden {display: none;}
.post-type-archive-espresso_events .type-article.tag-hidden {display: none;}

can u please help


Josh

  • Support Staff

March 2, 2018 at 1:55 pm

Hi Khalid,

I can recommend a different approach that doesn’t use CSS, that still makes use of the hidden tag you’ve applied already.

You can add this PHP code to your site to remove those events from the event lists:

add_filter( 'posts_where', 'ee_remove_hidden_tagged_event_list', 25, 2 );
function ee_remove_hidden_tagged_event_list( $SQL, WP_Query $wp_query ) {
    global $wpdb;
    if ( 
        isset( $wp_query->query_vars['post_type'] ) && 
        ( $wp_query->query_vars['post_type'] == 'espresso_events'  ||
        ( is_array( $wp_query->query_vars['post_type'] ) && 
        in_array( 'espresso_events', $wp_query->query_vars['post_type'] ) ) ) &&
        ! $wp_query->is_singular ) {
            $SQL .= " AND ID NOT IN (SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id=186 )"; // change to hidden tag ID
    }
    return $SQL;
}

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


Khalid Joharji

March 3, 2018 at 7:00 am

I couldn’t access plugin editor for some reason since the wordpress version is installed through Godaddy. so i tried the second option and added it to theme’s functions.php but it did not work

please check the code, (the theme used is baskerville)
https://s18.postimg.org/ittaceu6h/image.png


Khalid Joharji

March 5, 2018 at 6:05 am

kind reminder


Josh

  • Support Staff

March 5, 2018 at 9:36 am

You can use FTP to upload files with code to your site’s wp-content/plugins folder. This guide has more details:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

Viewing 4 reply threads

The support post ‘Hiding events from the event list’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso