Output wp_list_pages Using Dynamic meta_value (1 post)

  1. Joel
    Posted 7 years ago #

    Please forgive me, as I am a relative novice at PHP.

    Trying to use the get_post_custom_values & the wp_list_pages functions to publish a list using the following filters:

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

    Here is my current code:

    // Method To show list of subpages on a subpage with same parent
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    // This is where the problems begin
      $county_values = get_post_custom_values('County', $post->ID);
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&meta_key='County'&meta_value='".$county_values."'");
      if ($children) { ?>
      <?php echo $children; ?>
      <?php } ?>

    My sense is that there are one of two issues; either I'm incorrectly passing the tag parameters (i.e. I've used bad PHP syntax) or because I'm attempting to publish this code within the sidebar and it's outside of the loop.

    Many thanks for any help!

    Some Related Forum Posts:

    Some Related External Resources:

Topic Closed

This topic has been closed to new replies.

About this Topic