Remove Event Posts from Tag Archives

Home Forums Calendar Products Events Calendar PRO Remove Event Posts from Tag Archives

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1055575
    Anthony
    Participant

    I’m looking for an easy way to remove event posts from tag archives.

    Even when I filter my query by post type ‘post’ the events are still in the results.

    How can I get just my standard wordpress posts on tag archives / queries without events in there too?

    #1055640
    Barry
    Member

    Hi Anthony,

    You could try adding the following snippet either to your theme’s functions.php file or else to a custom plugin:

    /**
     * Show nothing but posts in tag archives.
     * 
     * @param WP_Query $query
     */
    function just_posts_in_tag_archives( WP_Query $query ) {
    	if ( ! $query->is_tag ) return;
    	$query->set( 'post_type', 'post' );
    }
    
    add_action( 'parse_query', 'just_posts_in_tag_archives', 100 );

    Does that help?

    #1058781
    Anthony
    Participant

    Thank you, I added the code to my functions.php file, and unfortunately I’m still getting events in the tag queries.

    Here is an example of where it is occurring: http://milwaukeefoodcouncil.org/food-system/farmers-markets/

    I’m trying to get posts only on top, and events only on bottom, on tag archive pages. Or, just posts on top without events on the bottom would be fine too.

    However, the events on the bottom piece is working fine, but I can’t get the events filtered out of the posts on the top, which is the main thing I am looking for.

    This is a genesis based implementation. Please advise.

    #1058828
    Barry
    Member

    Hi Anthony,

    I’m not sure what to suggest as it does work for me locally.

    Could you share your complete theme functions.php file (ideally via a Pastebin or Gist link) so I can take a look at where you added the code?

    Thanks!

    #1058839
    Anthony
    Participant

    No problem, here it is:

    http://pastebin.com/NuwrgMew

    #1058853
    Barry
    Member

    Thanks for sharing, though I’m afraid nothing obvious is jumping out at me there.

    On a clean installation with only a default theme, though, it does appear to me to work as expected. Quite why it’s failing in your case I’m not sure and, as customizations/custom dev tasks are something we can only offer very limited support for, I’m afraid I’ll need to leave the rest in your hands.

    Sorry I couldn’t get you what you needed on this occasion, but hopefully you’re able to come up with a working solution of your own 🙂

    #1058905
    Anthony
    Participant

    Ok, I understand you can only go so far with the support for customization.

    I am just wondering, if it’s not asking too much, and if you have not done so, could you maybe try it on a genesis framework installation?

    #1058920
    Barry
    Member

    OK – I just tested with Genesis and ….. same result as you experienced!

    Curiosity has the better of me now. Give me a little longer and I’ll see if there’s any obvious reason it doesn’t work under Genesis.

    #1058921
    Barry
    Member

    Actually, I take that back – the snippet does seem to work with Genesis (just the latest base theme, I didn’t try with any child themes).

    With that in mind, it could be worth performing a similar test of your own: if you strip things down to just our plugins, that snippet and the basic Genesis framework does it work for you then?

    Assuming it does, if you start reactivating the other components one-at-a-time do you find it suddenly stops working?

    #1076936
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Remove Event Posts from Tag Archives’ is closed to new replies.