• Resolved jasonabuck

    (@jasonabuck)


    Okay,

    I am new to WordPress and I am having problems showing only specific pages in the SideNav.

    I have created a CUSTOM FIELD called sidenav and set the value of that field to 1 on the pages I want to appear in the SideNav.

    Pages that have a value of 0 will appear in my TopNav.

    This code below queries and returns all of my pages. How do I get it to only return items where my CUSTOM FIELD sidenav has a value of 1.

    <?php

    // get the meta value for the key ‘foo’
    $Cluster = get_post_custom_values(‘sidebar’);

    // make sure that worked
    // print_r($Cluster); // I’m ok here, so far

    // if $Cluster not null, list the Pages with the custom key ‘foo’ and the value ‘bar’ THIS IS WHERE IT DOESN’T WORK:
    if ($Cluster !== ”) {

    echo ‘<div class=”article_links”>
    <h2>Side Nav</h2>

      ‘;
      wp_list_pages($Cluster);

      echo ‘

    </div><!– .article_links –>’;

    }
    ?>

    Thanks in Advance

Viewing 1 replies (of 1 total)
  • Thread Starter jasonabuck

    (@jasonabuck)

    <?php wp_list_pages(‘meta_key=sidebar&meta_value=0&sort_column=menu_order&title_li= &depth=1’); ?>

    This is the answer I was looking for.

    For all my pages that I enter into WordPress, I create a CUSTOM FIELD called sidebar and then set the value to 1 (on) for my side bar and 0 (off) if I want it to appear in my top nav.

    Thanks for the looks.

    The documentation for WordPress is great, just a little hard to find exactly what you are looking for as you try to learn as a newbie.

    Jason

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Fields and SideNav’ is closed to new replies.