Want display only children of a certain parent that I specify in loop
-
I have 2 custom post types: “Menu Items” and “Restaurants”. Within the Types plugin admin I set “Menu Items” to be a child of “Restaurants”. I have several “Menu Items” now attached to their respective “Restaurant”.
I’m using the WP_query loop to display my “Menu Items” in a list with the fields I’ve chosen and that is working fine. Here’s the beginning of that that looks like:
$args = array('post_type' => 'menu-items', 'meta_key' => 'wpcf-order', orderby => 'meta_value_num', order => 'ASC'); $query = new WP_Query($args); while($query -> have_posts()) : $query -> the_post(); $htmlTag = types_render_field( "html", array( 'raw' => true) ); echo $htmlTag; echo the_title(); $content = $post->post_content; echo $content;
etc
Now I want to filter this further to only display “Menu Items” that are a child of a certain “Restaurant” that I specify. Either by slug, or ID. I’m confused on how to do this with
types_child_posts
.I know I can use
post__in
in the$args
but I don’t know how to get the list of children post id’s into an indexed array.
- The topic ‘Want display only children of a certain parent that I specify in loop’ is closed to new replies.