Custom Query: Specific Category, Exclude Children

Home Forums Calendar Products Events Calendar PRO Custom Query: Specific Category, Exclude Children

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1368885
    tpdweb
    Participant

    Hello! I’m setting up a calendar using parent and children categories.

    I’m trying to query a specific category, however only the parent category, excluding all children. I have been unable to filter out children posts. I believe I read this must be done using tax_query for The Events Calendar.

    Is there any way to quickly do this or a better approach? I’ve tried 'post_parent' => 0, and searched for other manners but can’t seem to find a good solution.

    			$events = tribe_get_events( array(
    				 'start_date' => date( 'Y-m-d H:i:s', strtotime( '-28 week' ) ),
    				 'posts_per_page'=>-1,
    			 	 'tax_query'=> array(
    	                array(
    	                    'taxonomy' => 'tribe_events_cat',
    	                    'field' => 'slug',
    	                    'terms' => 'sat-courses',
    	                )
                )
    
    			) );
    #1369779
    Victor
    Member

    Hi Vanessa!

    Thanks for reaching out to us! Let me help you with this topic.

    First, please let me note that we are fairly limited in how much support we can give for custom development questions like that.

    That said, we always like helping out and at least point users into the right direction as much possible.

    I think you can achieve that by using the include_children property for the tax_query as it shows here > https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

    Please try that and let me know if it works for you.

    Best,
    Victor

    #1371531
    tpdweb
    Participant

    Perfect. Thanks!

    #1371661
    Victor
    Member

    Hey Vanessa!

    Glad to be of help here 🙂

    As you marked this Resolved I’ll go ahead and close it, but feel free to open a new topic if anything comes up and we’d be happy to help.

    Best,
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Custom Query: Specific Category, Exclude Children’ is closed to new replies.