这是整个修复过程。。。这需要大量的服务器负载,但它适用于已经到位的实现。
按特定区域的状态查找用户,并在表中显示所有帖子。
<?php
$wp_user_search1 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'TN\',
));
$listers1 = $wp_user_search1->get_results();
$lister_ids1 = array();
foreach($listers1 as $lister1) {
$lister_ids1[] = $lister1->ID;
}
$ids1 = implode(\',\', $lister_ids1);
$wp_user_search2 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'NC\',
));
$listers2 = $wp_user_search2->get_results();
$lister_ids2 = array();
foreach($listers2 as $lister2) {
$lister_ids2[] = $lister2->ID;
}
$ids2 = implode(\',\', $lister_ids2);
$wp_user_search3 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'SC\',
));
$listers3 = $wp_user_search3->get_results();
$lister_ids3 = array();
foreach($listers3 as $lister3) {
$lister_ids3[] = $lister3->ID;
}
$ids3 = implode(\',\', $lister_ids3);
$wp_user_search4 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'AL\',
));
$listers4 = $wp_user_search4->get_results();
$lister_ids4 = array();
foreach($listers4 as $lister4) {
$lister_ids4[] = $lister4->ID;
}
$ids4 = implode(\',\', $lister_ids4);
$wp_user_search5 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'GA\',
));
$listers5 = $wp_user_search5->get_results();
$lister_ids5 = array();
foreach($listers5 as $lister5) {
$lister_ids5[] = $lister5->ID;
}
$ids5 = implode(\',\', $lister_ids5);
$wp_user_search6 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers6 = $wp_user_search6->get_results();
$lister_ids6 = array();
foreach($listers6 as $lister6) {
$lister_ids6[] = $lister6->ID;
}
$ids6 = implode(\',\', $lister_ids6);
$wp_user_search7 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers7 = $wp_user_search7->get_results();
$lister_ids7 = array();
foreach($listers7 as $lister7) {
$lister_ids7[] = $lister7->ID;
}
$ids7 = implode(\',\', $lister_ids7);
$wp_user_search8 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers8 = $wp_user_search8->get_results();
$lister_ids8 = array();
foreach($listers8 as $lister8) {
$lister_ids8[] = $lister8->ID;
}
$ids8 = implode(\',\', $lister_ids8);
$wp_user_search9 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers9 = $wp_user_search9->get_results();
$lister_ids9 = array();
foreach($listers9 as $lister9) {
$lister_ids9[] = $lister9->ID;
}
$ids9 = implode(\',\', $lister_ids9);
$wp_user_search10 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers10 = $wp_user_search10->get_results();
$lister_ids10 = array();
foreach($listers10 as $lister10) {
$lister_ids10[] = $lister10->ID;
}
$ids10 = implode(\',\', $lister_ids10);
$wp_user_search11 = new WP_User_Query( array(
\'meta_key\' => \'state\' ,
\'meta_value\' => \'FL\',
));
$listers11 = $wp_user_search11->get_results();
$lister_ids11 = array();
foreach($listers11 as $lister11) {
$lister_ids11[] = $lister11->ID;
}
$ids11 = implode(\',\', $lister_ids11);
$ids = $ids1.",". $ids2.",". $ids3.",". $ids4.",". $ids5.",". $ids6.",". $ids7.",". $ids8.",". $ids9.",". $ids10.",". $ids11;
$args = array(
\'post_type\' => \'listing\',
\'author\' => $ids,
\'posts_per_page\' => 10,
\'paged\' => $paged
);
$your_query = new WP_Query( $args );
if ( have_posts() ) : while ( $your_query->have_posts() ) : $your_query->the_post();?>
<?php
$custom = get_post_custom($post->ID);
$screenshot_url = $custom["screenshot_url"][0];
$website_url = $custom["website_url"][0];
?>
<tr>
<td class="td50 light"><div class="front_img"><a href="<?=$website_url?>"><?php postimage(\'thumbnail\'); ?></a></div></td>
<td class="td357 light"><a href="<?php the_permalink(); ?>"><strong><?php the_title(); ?></strong></a></td>
<td class="td40 light"><?php the_field( \'package_size\' ); ?></td>
<td class="td40 light"><?php the_field( \'product_condition\' ); ?></td>
<td class="td40 light"><?php the_field( \'product_quantity\' ); ?></td>
<td class="td40 light">$<?php the_field( \'asking_price\' ); ?><br />Per <?php the_field( \'package_quantity\' ); ?></td>
<td class="td40 light">
<?php if (get_the_author_meta(\'state\') == \'WA\') { ?>1
<?php } elseif (get_the_author_meta(\'state\') == \'OR\') { ?>1
<?php } elseif (get_the_author_meta(\'state\') == \'ID\') { ?>1
<?php } elseif (get_the_author_meta(\'state\') == \'AZ\') { ?>2
<?php } elseif (get_the_author_meta(\'state\') == \'CA\') { ?>2
<?php } elseif (get_the_author_meta(\'state\') == \'NV\') { ?>2
<?php } elseif (get_the_author_meta(\'state\') == \'UT\') { ?>2
<?php } elseif (get_the_author_meta(\'state\') == \'MT\') { ?>3
<?php } elseif (get_the_author_meta(\'state\') == \'WY\') { ?>3
<?php } elseif (get_the_author_meta(\'state\') == \'ND\') { ?>3
<?php } elseif (get_the_author_meta(\'state\') == \'SD\') { ?>3
<?php } elseif (get_the_author_meta(\'state\') == \'CO\') { ?>4
<?php } elseif (get_the_author_meta(\'state\') == \'NE\') { ?>4
<?php } elseif (get_the_author_meta(\'state\') == \'KS\') { ?>4
<?php } elseif (get_the_author_meta(\'state\') == \'IA\') { ?>4
<?php } elseif (get_the_author_meta(\'state\') == \'MO\') { ?>4
<?php } elseif (get_the_author_meta(\'state\') == \'NM\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'TX\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'OK\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'AR\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'MS\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'LA\') { ?>5
<?php } elseif (get_the_author_meta(\'state\') == \'MN\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'WI\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'IL\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'IN\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'MI\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'OH\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'KY\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'WV\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'VA\') { ?>6
<?php } elseif (get_the_author_meta(\'state\') == \'TN\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'NC\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'SC\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'AL\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'GA\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'FL\') { ?>7
<?php } elseif (get_the_author_meta(\'state\') == \'PA\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'NY\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'ME\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'VT\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'NH\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'MA\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'RI\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'CT\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'NJ\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'DE\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'MD\') { ?>8
<?php } elseif (get_the_author_meta(\'state\') == \'AK\') { ?>9
<?php } elseif (get_the_author_meta(\'state\') == \'HI\') { ?>9
<?php } else { ?> <?php } ?>
</td>
</tr>
<?php endwhile; endif; ?>
</table>
<div id="paginav">
<div class="alignright">
<?php if ( function_exists(\'wp_pagenavi\') ) {
wp_pagenavi( array( \'query\' => $your_query ) );
}
elseif ( get_next_posts_link() || get_previous_posts_link() )
previous_posts_link( \'Previous »\' );
next_posts_link( \'« Next\', $your_query->max_num_pages );
?>
<?php wp_reset_query(); ?>