wordpress查询自定义字段为特定值的文章

wordpress查询自定义字段为特定值的文章

<?php
		$args = array(
		'post_type' => 'post',
		'meta_key'=>'identityNo',
		'post_status'=> 'publish',
		'posts_per_page' => -1,
		'meta_query' => array(
			array(
				'key' => 'identityNo',
				'value' => $_POST['identityNo'],
			),
		)
	);
	$nQuery = new WP_Query( $args );
        if ( $nQuery -> have_posts() ) {
        while ( $nQuery ->have_posts() ) : $nQuery ->the_post();
	//loop
         endwhile;

	}
?>

参考资料:

http://jokerliang.com/wordpress-custom-fields-to-support-between-queries.html

https://codex.wordpress.org/Class_Reference/WP_Query

未经允许不得转载:WEIXING.ME » wordpress查询自定义字段为特定值的文章

相关文章

评论 (0)