display page of post depending on post type and custom field - wordpress
I'm trying to display a page of post bas开发者_运维百科ed on the post type and custom field.
This is what I have so far. It seems to display the posts only from the 'new' post type how I'd like but now I'd like to also filter based on the custom field value and I'm not sure how.
<?php
$args = array( 'post_type' => 'new', 'posts_per_page' => 10);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content()
echo '</div>';
endwhile; ?>
Also I was wondering how I'd got about adding pagination to this.
Thanks!
You should be able to filter by custom fields (metas) with:
'meta_key=keyname&meta_value=meta_value'
Pagination with custom queries is nicely explained here: http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/
精彩评论