WordPress if-menu condition

I am using https://wordpress.org/plugins/if-menu/ to create a condition to show a parent and sub pages on certain pages.

add_filter( 'if_menu_conditions', 'my_new_menu_condition' );

function my_new_menu_condition( $conditions ) {

global $post;

$conditions[] = array(
    'name'    =>  'Condition Name', // name of the condition
    'condition' =>  function($item) {          // callback - must return TRUE or FALSE
      return is_page('Parent Page' ) || is_page('Parent Page' ) && $post->post_parent > 0;

  return $conditions;

I am not having much luck. Does anyone have any experience with this plugin and know if this is possible?


Read more here: WordPress if-menu condition

Leave a Reply

Your email address will not be published. Required fields are marked *