Now that we learned almost everything about theWP_Queryclass, it’s time to try out some examples. In this part, we’re going to work on 10 different scenarios to utilize theWP_Queryclass and related functions. It will be a fun exercise and I hope it will be equally educational. Let...
以下为原文:http://code.tutsplus.com/tutorials/wp_query-arguments-status-order-and-pagination–cms-23167 In this part of the series on MasteringWP_Query, you’ll learn about some of the arguments you can use with theWP_Queryclass, namely those for: status order pagination You can use these...
//codex.wordpress.org/Class_Reference/WP_Query#Post_Field_Parameters /** * 过滤器 */ //关于过滤器的更多信息,请参考:http://codex.wordpress.org/Class_Reference/WP_Query#Filters ); $the_query = new WP_Query( $args ); // 循环开始 if ( $the_query->have_posts() ) : while ( $the_...
<h2 class="custom-post-title"><?php the_title(); ?></h2> <div class="custom-post-content"><?php the_content(); ?></div> 通过以上步骤,你就可以在WordPress中使用WP_Query来自定义文章的显示,并根据需要进行样式调整。
在WordPress6.0 之前,WP_User_Queryclass 的 fileds 参数支持ID和all_with_meta/all这三个选项。 升级到 WordPress 6.0 之后,可以给fields传递下面这些这些选项中的任何一个并获取相关的值: ID display_name user_login user_pass user_nicename user_email ...
//http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters 'p' => 1, //(int) - use post id. 'name' => 'hello-world', //(string) - use post slug. 'page_id' => 1, //(int) - use page id. 'pagename' => 'sample-page', //(string) - use page ...
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters 'author'=>'1,2,3,',//(int) - use author id [use minus (-) to exclude authors by ID ex. 'author' => '-1,-2,-3,'] 'author_name'=>'luetkemj',//(string) - use 'user_nicename' (NOT name) ...
In this guide I am assuming that you already have some basic knowledge how to work with WP_Query class in WordPress. And this tutorial will be all about working with custom fields. Either you are working with Gutenberg or with Classic Editor, maybe you’re using some custom fields plugins ...
) ."' class='extend' title='跳转到最后一页'>尾页"; } echo '共['.$max_page.']页'; echo "\n"; } } ?>调用分页:<?php // 1.用于查询的参数或者参数集合 $args = array( 'post_type'=>'post', 'posts_per_page'=>3, 'paged'=>get_query_var('paged') ); // 2.查询 $myquery...
您可能注意到了前面示例中的 ($args) 行。这是您将包含查询参数的地方。 要构造您的WP_Query args,您需要将某些参数放在一个数组中。我们将在下一节讨论参数,但下面是基本参数的外观: $args=array( 'parameter1'=>'value', 'parameter2'=>'value', ...