全部的
我希望那些帖子的post\\u type==profile,wpcf gender==1(男性)。
我试过这个密码
$wp_query = new WP_Query( array( \'meta_key\' => \'wpcf-gender\', \'meta_value\' => \'1\', \'meta_compare\' => \'==\', \'post_type\' => \'profile\',\'posts_per_page\' => 2 ) );
我得到的结果很完美,但分页不起作用。你能帮我找到下面代码中的问题吗?
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query( array( \'meta_key\' => \'wpcf-gender\', \'meta_value\' => \'1\', \'meta_compare\' => \'==\', \'post_type\' => \'profile\',\'posts_per_page\' => 2 ) );
?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2 class="page-title"><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2>
<div class="page-image">
<div class="page-image-overlay-child"></div>
<span style="float: left;padding-right: 50px;">
<?php
if(has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo \'<img src="\'.get_bloginfo("template_url").\'/images/header-image-1.jpg" alt="" />\';
}
?>
</span>
<table>
<th></th>
<tr>
<td style="padding: 10px;"><strong>First Name:</strong> <?php echo do_shortcode(\'[types field="first-name" class="" style=""]\'); ?></td>
<td style="padding: 10px;"><strong>Last Name:</strong> <?php echo do_shortcode(\'[types field="last-name" class="" style=""]\'); ?></td>
</tr>
<tr>
<td style="padding: 10px;"><strong>Gender:</strong> <?php echo do_shortcode(\'[types field="gender"][/types]\'); ?></td>
<td style="padding: 10px;"><strong>DOB:</strong> <?php echo do_shortcode(\'[types field="dob" style="text" format="F j, Y"][/types]\'); ?></td>
</tr>
<tr>
<td style="padding: 10px;"><strong>City:</strong> <?php echo do_shortcode(\'[types field="city"]\'); ?></td>
<td style="padding: 10px;"><strong>State:</strong> <?php echo do_shortcode(\'[types field="state"]\'); ?></td>
</tr>
</table>
</div>
<div class="divider"></div>
<div class="entry">
<?php the_excerpt(); ?>
<input type="button" value="Read more..." id="searchsubmit" class="readmore" onClick="javascript:location.href = \'<?php the_permalink();?>\';" >
</div>
<div class="divider"></div>
</div>
<?php endwhile; ?>
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $wp_query->max_num_pages
));?>