1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wordpress menu displays all child page link but also want to filter to be based on custom field

Discussion in 'PHP' started by macaela, Sep 9, 2014.

  1. #1
    Hi I've got this menu that display all the child page menu of the current page works fine to that point, but i now only want to display the child pages that custom field has value of (thememenu) but it still diaply all the child page when I try help please

    <ul>
    <?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()) );

    ?>
    </ul>
    SEMrush
     
    macaela, Sep 9, 2014 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Question: why don't you use the built in wp menu system? (ie, from the admin panel)
     
    PoPSiCLe, Sep 9, 2014 IP