kathrynp
Member
Posted 2 years ago #
I'm trying to list all pages that have a meta_key of 'teams' but I want to list out the title of the page (as a link to the page) and the meta_value for meta_key 'number'... similar to what gotham girls have here:
http://www.gothamgirlsrollerderby.com/people/players
is this possible? right now I'm using:
<?php
wp_list_pages("meta_key=team&hierarchical=0");
?>
but I feel like maybe I need to use query_pages
any help is much appreciated.
<?php
$metakey = 'teams';
$args=array(
'meta_key'=> $metakey,
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of Pages with custom field ' . $metakey;
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
$team = get_post_meta($my_query->post->ID, $metakey, true);
if ($team){
echo 'Team is '.$team;
}
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
kathrynp
Member
Posted 2 years ago #
kathrynp
Member
Posted 2 years ago #
How can I list just pages who have a meta_key of 'team' who's meta_value of 'team' is 'team a'? And still list their number after? Sorry, I'm not that amazing at PHP.
$args=array(
'meta_key'=> $metakey,
'meta_value' => 'team',
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);