Support » Fixing WordPress » wp_list_pages Syntax with meta_key & meta_value Parameters?

  • I’m trying to use wp_list_pages with the meta_key and meta_value parameters, but I’m messing it up. I searched and searched for this, but couldn’t find it posted previously. I have read the wp_list_pages() page from Codex over and over, but I guess I’m just thick-headed.

    I created Pages with a Custom Field Key of “cluster” (no quotes) and a value of “info” (no quotes). I’m trying to use wp_list_pages to list only the pages containing that key/value pair.

    So far, I have:

    <?php wp_list_pages('title_li=&sort_column=post_title&include=4&meta_key=cluster&meta_value=info' ) ?>

    I’ve tried the meta_key and meta_value = with quotes and without, but it doesn’t work.

    Anyone know how to format these parameters correctly??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Couple options that may work for you:

    1. Have you tried reordering the arguments so that title_li comes last?

    title_li=' ) ?>

    2. Use the method described here:

    $PageOptions =array(
    'title_li' => '',

    Thanks very much.

    OMG!!! it worked!!!! thank you very much mlstt!!! I was getting nuts to make this work too ^_^

    Does anyone know how to use a dynamic meta_value parameter for the wp_list_pages function? Can’t seem to get it to work.

    Here’s what I currently am using:

    	// Method To show subpages on a subpage
    	$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    	// Attempt to Call 'County' meta_value
    	$county = get_post_custom_values("County");
    	// Attempt to Filter Pages by adding 'County' meta_value
    	$children = wp_list_pages('
            title_li=' );
    	if ($children) { ?>
    		<?php echo $children; ?>
    	<?php } ?>

    I’d like to limit the list so that it only returns items which are a child page (which I have successfully achieved) and which also contain the meta_value for the current pages meta_key=’County’ (which I haven’t achieved).

    Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_pages Syntax with meta_key & meta_value Parameters?’ is closed to new replies.