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:
- Show a list of pages that share the same parent (I was able to successfully apply this filter)
- 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:
<?php
// Method To show list of subpages on a subpage with same parent
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
// 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) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?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:
- wp_list_pages Syntax with meta_key & meta_value Parameters?
- List Pages with Specific meta key/value Help PLEASE?
- Question about get_post_custom_values in template
- if a specific key exists, change the output in get_pages
- Using get_post_custom_values out of the loop?
- Function Reference/get post meta
Some Related External Resources: