• Trying to use wp_list_pages() to generate a list of Pages, listing <b>only</b> those Pages with a specific meta key value (custom field value).

    So far, I’ve got this:

    < ? php
         // get the meta value for the key 'foo'
         $Cluster = get_post_custom_values('foo');
    
         // 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"><h4>Learn More</h4><ul>';
              wp_list_pages($Cluster);
              echo '</ul></div><!-- .article_links -->';
         }
         ?>

    Passing the $Cluster argument to the wp_list_pages function only results in an ul of ALL pages, not a list of Pages with only the key/value I want (foo/bar) in this example.

    The wp_list_pages page of Codex states I can use the function

    “restricted to Pages with specific meta key/meta value (not shown in defaults above)

    does ANYONE have an example of the correct syntax for wp_list_pages that restricts the list to Pages with specific meta key/values????

    PLEASE??

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Having a similar issue…I think.

    Since I’m relatively new to this, here’s my explanation in plain English:

    Trying to use the wp_list_pages function and two filters (parameters) to produce the desired result. Here are the two filters:

    1. Show a list of pages that share the same parent (I was able to successfully apply this filter)
    2. For the meta_key=’County’; show only pages which share the same meta_value (custom field value) as the page the are shown on .

    i.e.
    The parent page is Alaska and there is a subpage for each major city in Alaska (assume each subpage contains the required custom fields–meaning that each subpage has a meta_key=County & the meta_value=”corresponds to whatever County that City geographically falls within”).

    I would like to show a list on each subpage of the other subpages which match the meta_value for meta_key=’County’ (meaning that the subpages shown will all be in the same County as the subpage displaying them).

    Many thanks for any help!

Viewing 1 replies (of 1 total)
  • The topic ‘List Pages with Specific meta key/value Help PLEASE?’ is closed to new replies.