Provide zblog template_zblog them_wordpress template download and customization

Wordpress calls specified field article data+specified field sorting

Tianxing Studio 2021-12-30 20:37 Wordpress Tutorial one thousand two hundred and twelve 0 Comments


wordpress The fields in the main table of articles are very compact. The number of views needs to be written to the meta table to query the associated table. If you want to call the article data according to the number of views, you can use the "get_posts()" function to do this:

 $args = array( 'numberposts'=>Number of calls (integer),     'orderby' => 'meta_value_num', 'meta_key '=>The name of the sorting meta field is generally views,     'order' => 'DESC', );

However, if you want to get the article data of the specified field while sorting by browsing, because you need to specify the name of the meta field, the two "meta_keys" must be repeated, so you have to write this:

 $args = array( 'numberposts'=>Number of calls (integer),     'orderby' => 'meta_value_num', 'meta_key '=>The name of the sorting meta field is generally views,     'order' => 'DESC',     'meta_query' => array(         array( 'key'=>Field name, 'value'=>Field value         )     ) );

Finally, give the array to the "get_posts()" function, and it's OK.

 $array = query_posts($args);

PS: You can call more types of article data after you can play these tricks.


Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login