• 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:

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

    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?

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

    2. Use the method described here:
    http://contents-magic.com/29/wordpress/including-a-better-navigation-for-wordpress-pages/

    $PageOptions =array(
    'title_li' => '',
    'meta_key'=>'cluster',
    'meta_value'=>'info'
    );
    wp_list_pages($PageOptions);
    Thread Starter jdcpar5

    (@jdcpar5)

    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:

    <?php
    	// Method To show subpages on a subpage
    	if($post->post_parent)
    	$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    	else
    	// 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('
            child_of='.$post->ID.'&
            echo=0&
            meta_key='.$county.'&
            title_li=' );
    	if ($children) { ?>
    	<ul>
    		<?php echo $children; ?>
    	</ul>
    	<?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.