Wordpress display menu if is child page of current page and custom value equals

I already got the menu to display links of child pages to appear I just need to only display links of child pages that the custom field is equal to (thememenu)

<?php // display all the child and granchild page links exclude link of page parent_pages_to_exclude $extra_menu = get_post_meta($post->ID, 'extra_menu', true); $parent_pages_to_exclude = array(198,701,3247); // excluded pages foreach($parent_pages_to_exclude as $value) { // for each value inside array parent_pages_to_exclude add the value in the variable value if ($page_exclusions) { $page_exclusions .= ',' . $value && $extra_menu == "thememenu"; } // this has the values of all the child pages excluded and included else { $page_exclusions = $value; } } wp_list_pages( array('title_li'=>'','depth'=>3, 'exclude'=>$page_exclusions,'child_of'=>get_post_top_ancestor_id()) ); ?>

Let me see if I understand you correctly. You just want to show links to the hierarchy beneath a specific parent page?

I use a plugin called Flexi Pages widget to achieve this. Instead of adding it as a widget, I insert it directly into my template file with some additional code to determine whether the topmost parent has any children, with it only producing the output if it does.

I use https://github.com/miya0001/child-pages-shortcode give it a try