Loading [MathJax]/jax/output/CommonHTML/config.js
前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >全部WordPress查询数组参考

全部WordPress查询数组参考

原创
作者头像
小颖club
发布于 2022-04-12 13:08:46
发布于 2022-04-12 13:08:46
77700
代码可运行
举报
文章被收录于专栏:建站技术博客建站技术博客
运行总次数:0
代码可运行

WordPress输出内容时用到最多的就是$args =array( 这个查询数组,这篇文章给大家分享所有的,WordPress查询综合参考

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$args = array(

在这里先分享一个简单的案例:

当我们做网站时,使用query_posts查询得到的结果很多的情况下就需要进行分页。实现query_posts查询结果分页的代码如下:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<?php

$paged = $_GET['paged'] ? $_GET['paged'] : 1;

//常规排序方法
$args=array(
'post_type' => 'post',//WordPress 帖子类型:帖子
'post_status'=>'publish',//WordPress 发布状态:发布
'cat' => $cat, // 分类ID
'meta_key' => 'paixu',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'paged' => $paged,
'posts_per_page' => '28', // 显示篇数
);

//查询文章
$query = new WP_Query( $args );
while ($query->have_posts()) : $query->the_post(); ?>
<li class="clearfix"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>

下面就是全部参考:全部WordPress查询数组参考(后面灰色文字就是解释,我实在没工夫翻译,你们可以翻译看看解释及用法)

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<?php
/**

*/

$args = array(


  'author' => '1,2,3,', // (int | string) -  use author id or comma-separated list of IDs [use minus (-) to exclude authors by ID ex. 'author' => '-1,-2,-3,']
  'author_name' => 'luetkemj', // (string) - use 'user_nicename' (NOT name)
  'author__in' => array( 2, 6 ), // (array) - use author id (available with Version 3.7).
  'author__not_in' => array( 2, 6 ), // (array)' - use author id (available with Version 3.7).

// Category Parameters - Show posts associated with certain categories.
// http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
  'cat' => 5, // (int) - Display posts that have this category (and any children of that category), using category id.
  'cat' => '-12,-34,-56' // Display all posts except those from a category by prefixing its id with a '-' (minus) sign.
  'category_name' => 'staff, news', // (string) - Display posts that have these categories (and any children of that category), using category slug.
  'category_name' => 'staff+news', // (string) - Display posts that have "all" of these categories, using category slug.
  'category__and' => array( 2, 6 ), // (array) - Display posts that are in multiple categories. This shows posts that are in both categories 2 and 6.
  'category__in' => array( 2, 6 ), // (array) - Display posts that have this category (not children of that category), using category id.
  'category__not_in' => array( 2, 6 ), // (array) - Display posts that DO NOT HAVE these categories (not children of that category), using category id.

// Tag Parameters - Show posts associated with certain tags.
// http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
  'tag' => 'cooking', // (string) - use tag slug.
  'tag_id' => 5, // (int) - use tag id.
  'tag__and' => array( 2, 6), // (array) - use tag ids.
  'tag__in' => array( 2, 6), // (array) - use tag ids.
  'tag__not_in' => array( 2, 6), // (array) - use tag ids.
  'tag_slug__and' => array( 'red', 'blue'), // (array) - use tag slugs.
  'tag_slug__in' => array( 'red', 'blue'), // (array) - use tag slugs.

// Taxonomy Parameters - Show posts associated with certain taxonomy.
// http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
// Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays)
// This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy queries.
  'tax_query' => array( // (array) - use taxonomy parameters (available with Version 3.1).
    'relation' => 'AND', // (string) - The logical relationship between each inner taxonomy array when there is more than one. Possible values are 'AND', 'OR'. Do not use with a single inner taxonomy array. Default value is 'AND'.
    array(
      'taxonomy' => 'color', // (string) - Taxonomy.
      'field' => 'slug', // (string) - Select taxonomy term by Possible values are 'term_id', 'name', 'slug' or 'term_taxonomy_id'. Default value is 'term_id'.
      'terms' => array( 'red', 'blue' ), // (int/string/array) - Taxonomy term(s).
      'include_children' => true, // (bool) - Whether or not to include children for hierarchical taxonomies. Defaults to true.
      'operator' => 'IN' // (string) - Operator to test. Possible values are 'IN', 'NOT IN', 'AND', 'EXISTS' and 'NOT EXISTS'. Default value is 'IN'.
    ),
    array(
      'taxonomy' => 'actor',
      'field' => 'id',
      'terms' => array( 103, 115, 206 ),
      'include_children' => false,
      'operator' => 'NOT IN'
    )
  ),

// Post & Page Parameters - Display content based on post and page parameters.
// 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.
  'title' => 'Hello World' // (string) - use post title (available with Version 4.4)
  'page_id' => 1, // (int) - use page id.
  'pagename' => 'sample-page', // (string) - use page slug.
  'pagename' => 'contact_us/canada', // (string) - Display child page using the slug of the parent and the child page, separated ba slash
  'post_name__in' => 'sample-post' (array) // - use post slugs. Specify posts to retrieve. (available since Version 4.4)
  'post_parent' => 1, // (int) - use page id. Return just the child Pages. (Only works with heirachical post types.)
  'post_parent__in' => array(1,2,3) // (array) - use post ids. Specify posts whose parent is in an array. NOTE: Introduced in 3.6
  'post_parent__not_in' => array(1,2,3), // (array) - use post ids. Specify posts whose parent is not in an array.
  'post__in' => array(1,2,3), // (array) - use post ids. Specify posts to retrieve. ATTENTION If you use sticky posts, they will be included (prepended!) in the posts you retrieve whether you want it or not. To suppress this behaviour use ignore_sticky_posts
  'post__not_in' => array(1,2,3), // (array) - use post ids. Specify post NOT to retrieve.
  // NOTE: you cannot combine 'post__in' and 'post__not_in' in the same query

// Password Parameters - Show content based on post and page parameters. Remember that default post_type is only set to display posts but not pages.
// http://codex.wordpress.org/Class_Reference/WP_Query#Password_Parameters
  'has_password' => true, // (bool) - available with Version 3.9
                          // true for posts with passwords;
                          // false for posts without passwords;
                          // null for all posts with and without passwords
  'post_password' => 'multi-pass', // (string) - show posts with a particular password (available with Version 3.9)

// Post Type Parameters - Show posts associated with certain type or status.
// http://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
  'post_type' => array( // (string / array) - use post types. Retrieves posts by Post Types, default value is 'post';
    'post', // - a post.
    'page', // - a page.
    'revision', // - a revision.
    'attachment', // - an attachment. The default WP_Query sets 'post_status'=>'published', but atchments default to 'post_status'=>'inherit' so you'll need to set the status to 'inherit' or 'any'.
    'nav_menu_item' // - a navigation menu item
    'my-custom-post-type', // - Custom Post Types (e.g. movies)
  ),
  // NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
  'post_type' => 'any', // - retrieves any type except revisions and types with 'exclude_from_search' set to true.

// Post Status Parameters - Show posts associated with certain type or status.
// http://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters
    'post_status' => array( // (string | array) - use post status. Retrieves posts by Post Status, default value i'publish'.
      'publish', // - a published post or page.
      'pending', // - post is pending review.
      'draft',  // - a post in draft status.
      'auto-draft', // - a newly created post, with no content.
      'future', // - a post to publish in the future.
      'private', // - visible only to the author, administrators, and editors.
      'inherit', // - a revision. see get_children.
      'trash', // - post is in trashbin (available with Version 2.9).
    ),
    // NOTE: The 'any' keyword available to both post_type and post_status queries cannot be used within an array.
    'post_status' => 'any', // - retrieves any status except those from post types with 'exclude_from_search' set to true.


// Comment Paremters - @since Version 4.9 Introduced the `$comment_count` parameter.
// https://codex.wordpress.org/Class_Reference/WP_Query#Comment_Parameters
    'comment_count' => 10 // (int | array) The amount of comments your CPT has to have ( Search operator will do a '=' operation )
    'comment_count' => array(
      'value' => 10 // (int) - The amount of comments your CPT has to have when comparing
      'compare' => '=' // (string) - The search operator. Possible values are '=', '!=', '>', '>=', '<', '<='. Default value is '='.
    )

// Pagination Parameters
    //http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
    'posts_per_page' => 10, // (int) - number of post to show per page (available with Version 2.1). Use 'posts_per_page' => -1 to show all posts.
                            // Note: if the query is in a feed, wordpress overwrites this parameter with the stored 'posts_per_rss' option. Treimpose the limit, try using the 'post_limits' filter, or filter 'pre_option_posts_per_rss' and return -1
    'nopaging' => false, // (bool) - show all posts or use pagination. Default value is 'false', use paging.
    'paged' => get_query_var('paged'), // (int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
                                       // NOTE: Use get_query_var('page'); if you want your query to work in a Page template that you've set as your static front page. The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.
    'nopaging' => false, // (boolean) - show all posts or use pagination. Default value is 'false', use paging.
    'posts_per_archive_page' => 10, // (int) - number of posts to show per page - on archive pages only. Over-rides posts_per_page and showposts on pages where is_archive() or is_search() would be true.
    'offset' => 3, // (int) - number of post to displace or pass over.
                   // Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination. for a workaround see: http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination
                   // The 'offset' parameter is ignored when 'posts_per_page'=>-1 (show all posts) is used.
    'paged' => get_query_var('paged'), // (int) - number of page. Show the posts that would normally show up just on page X when usinthe "Older Entries" link.
                                       // NOTE: This whole paging thing gets tricky. Some links to help you out:
                                       // http://codex.wordpress.org/Function_Reference/next_posts_link#Usage_when_querying_the_loop_with_WP_Query
                                       // http://codex.wordpress.org/Pagination#Troubleshooting_Broken_Pagination
    'page' => get_query_var('page'), // (int) - number of page for a static front page. Show the posts that would normally show up just on page X of a Static Front Page.
                                     // NOTE: The query variable 'page' holds the pagenumber for a single paginated Post or Page that includes the <!--nextpage--> Quicktag in the post content.
    'ignore_sticky_posts' => false, // (boolean) - ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 - don't ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.

// Order & Orderby Parameters - Sort retrieved posts.
// http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
    'order' => 'DESC', // (string) - Designates the ascending or descending order of the 'orderby' parameter. Default to 'DESC'.
                       //Possible Values:
                       //'ASC' - ascending order from lowest to highest values (1, 2, 3; a, b, c).
                       //'DESC' - descending order from highest to lowest values (3, 2, 1; c, b, a).
    'orderby' => 'date', // (string) - Sort retrieved posts by parameter. Defaults to 'date'. One or more options can be passed. EX: 'orderby' => 'menu_order title'
                         //Possible Values:
                         // 'none' - No order (available since Version 2.8).
                         // 'ID' - Order by post id. Note the capitalization.
                         // 'author' - Order by author. ('post_author' is also accepted.)
                         // 'title' - Order by title. ('post_title' is also accepted.)
                         // 'name' - Order by post name (post slug). ('post_name' is also accepted.)
                         // 'type' - Order by post type (available since Version 4.0). ('post_type' is also accepted.)
                         // 'date' - Order by date. ('post_date' is also accepted.)
                         // 'modified' - Order by last modified date. ('post_modified' is also accepted.)
                         // 'parent' - Order by post/page parent id. ('post_parent' is also accepted.)
                         // 'rand' - Random order. You can also use 'RAND(x)' where 'x' is an integer seed value.
                         // 'comment_count' - Order by number of comments (available since Version 2.9).
                         // 'relevance' - Order by search terms in the following order: First, whether the entire sentence is matched. Second, if all the search terms are within the titles. Third, if any of the search terms appear in the titles. And, fourth, if the full sentence appears in the contents.
                         // 'menu_order' - Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct 'menu_order' values (they all default to 0).
                         // 'meta_value' - Note that a 'meta_key=keyname' must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use 'meta_value_num' instead for numeric values.
                         // 'meta_type' if you want to cast the meta value as a specific type. Possible values are 'NUMERIC', 'BINARY',  'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED', same as in '$meta_query'. When using 'meta_type' you can also use 'meta_value_*' accordingly. For example, when using DATETIME as 'meta_type' you can use 'meta_value_datetime' to define order structure.
                         // 'meta_value_num' - Order by numeric meta value (available since Version 2.8). Also note that a 'meta_key=keyname' must also be present in the query. This value allows for numerical sorting as noted above in 'meta_value'.
                         // 'post__in' - Preserve post ID order given in the 'post__in' array (available since Version 3.5). Note - the value of the order parameter does not change the resulting sort order.
                         // 'post_name__in' - Preserve post slug order given in the 'post_name__in' array (available since Version 4.6). Note - the value of the order parameter does not change the resulting sort order.
                         // 'post_parent__in' - Preserve post parent order given in the 'post_parent__in' array (available since Version 4.6). Note - the value of the order parameter does not change the resulting sort order.

// Date Parameters - Show posts associated with a certain time and date period.
// http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
    'year' => 2014, // (int) - 4 digit year (e.g. 2011).
    'monthnum' => 4, // (int) - Month number (from 1 to 12).
    'w' =>  25, // (int) - Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependenon the "start_of_week" option.
    'day' => 17, // (int) - Day of the month (from 1 to 31).
    'hour' => 13, // (int) - Hour (from 0 to 23).
    'minute' => 19, // (int) - Minute (from 0 to 60).
    'second' => 30, // (int) - Second (0 to 60).
    'm' => 201404, // (int) - YearMonth (For e.g.: 201307).
    'date_query' => array( // (array) - Date parameters (available with Version 3.7).
                           // these are super powerful. check out the codex for more comprehensive code examples http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
      array(
        'year' => 2014, // (int) - 4 digit year (e.g. 2011).
        'month' => 4, // (int) - Month number (from 1 to 12).
        'week' => 31, // (int) - Week of the year (from 0 to 53).
        'day' => 5, // (int) - Day of the month (from 1 to 31).
        'hour' => 2, // (int) - Hour (from 0 to 23).
        'minute' => 3, // (int) - Minute (from 0 to 59).
        'second' => 36, // (int) - Second (0 to 59).
        'after' => 'January 1st, 2013', // (string/array) - Date to retrieve posts after. Accepts strtotime()-compatible string, or array of 'year', 'month', 'day'
        'before' => array( // (string/array) - Date to retrieve posts after. Accepts strtotime()-compatible string, or array of 'year', 'month', 'day'
          'year' => 2013, // (string) Accepts any four-digit year. Default is empty.
          'month' => 2, // (string) The month of the year. Accepts numbers 1-12. Default: 12.
          'day' => 28, // (string) The day of the month. Accepts numbers 1-31. Default: last day of month.
        ),
        'inclusive' => true, // (boolean) - For after/before, whether exact value should be matched or not'.
        'compare' =>  '=', // (string) - Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP >= 3.5), and 'NOT EXISTS' (also only in WP >= 3.5). Default value is '='
        'column' => 'post_date', // (string) - Column to query against. Default: 'post_date'.
        'relation' => 'AND', // (string) - OR or AND, how the sub-arrays should be compared. Default: AND.
      ),
    ),

// Custom Field Parameters - Show posts associated with a certain custom field.
// http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
    'meta_key' => 'key', // (string) - Custom field key.
    'meta_value' => 'value', // (string) - Custom field value.
    'meta_value_num' => 10, // (number) - Custom field value.
    'meta_compare' => '=', // (string) - Operator to test the 'meta_value'. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'NOT EXISTS', 'REGEXP', 'NOT REGEXP' or 'RLIKE'. Default value is '='.
    'meta_query' => array( // (array) - Custom field parameters (available with Version 3.1).
      'relation' => 'AND', // (string) - Possible values are 'AND', 'OR'. The logical relationship between each inner meta_query array when there is more than one. Do not use with a single inner meta_query array.
       array(
         'key' => 'color', // (string) - Custom field key.
         'value' => 'blue', // (string/array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN') Using WP < 3.9? Check out this page for details: http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
         'type' => 'CHAR', // (string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'. The 'type' DATE works with the 'compare' value BETWEEN only if the date is stored at the format YYYYMMDD and tested with this format.
                           //NOTE: The 'type' DATE works with the 'compare' value BETWEEN only if the date is stored at the format YYYYMMDD and tested with this format.
         'compare' => '=', // (string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN', 'EXISTS' (only in WP >= 3.5), and 'NOT EXISTS' (also only in WP >= 3.5). Default value is '='.
       ),
       array(
         'key' => 'price',
         'value' => array( 1,200 ),
         'compare' => 'NOT LIKE',
       )
    ),

// Permission Parameters - Display published posts, as well as private posts, if the user has the appropriate capability:
// http://codex.wordpress.org/Class_Reference/WP_Query#Permission_Parameters
    'perm' => 'readable', // (string) Possible values are 'readable', 'editable'

// Mime Type Parameters - Used with the attachments post type.
// https://codex.wordpress.org/Class_Reference/WP_Query#Mime_Type_Parameters
    'post_mime_type' => 'image/gif', // (string/array) - Allowed mime types.


// Caching Parameters
// http://codex.wordpress.org/Class_Reference/WP_Query#Caching_Parameters
// NOTE Caching is a good thing. Setting these to false is generally not advised.
    'cache_results' => true, // (bool) Default is true - Post information cache.
    'update_post_term_cache' => true, // (bool) Default is true - Post term information cache.
    'update_post_meta_cache' => true, // (bool) Default is true - Post meta information cache.
    'no_found_rows' => false, // (bool) Default is false. WordPress uses SQL_CALC_FOUND_ROWS in most queries in order to implement pagination. Even when you don’t need pagination at all. By Setting this parameter to true you are telling wordPress not to count the total rows and reducing load on the DB. Pagination will NOT WORK when this parameter is set to true. For more information see: http://flavio.tordini.org/speed-up-wordpress-get_posts-and-query_posts-functions


// Search Parameter
// http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter
    's' => $s, // (string) - Passes along the query string variable from a search. For example usage see: http://www.wprecipes.com/how-to-display-the-number-of-results-in-wordpress-search
    'exact' => true, // (bool) - flag to make it only match whole titles/posts - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118
    'sentence' => true, // (bool) - flag to make it do a phrase search - Default value is false. For more information see: https://gist.github.com/2023628#gistcomment-285118

// Post Field Parameters
// For more info see: http://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter
// also https://gist.github.com/luetkemj/2023628/#comment-1003542
    'fields' => 'ids', // (string) - Which fields to return. All fields are returned by default.
                       // Possible values:
                       // 'ids'        - Return an array of post IDs.
                       // 'id=>parent' - Return an associative array [ parent => ID, … ].
                       // Passing anything else will return all fields (default) - an array of post objects.

// Filters
// For more information on available Filters see: http://codex.wordpress.org/Class_Reference/WP_Query#Filters

);

$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
  // Do Stuff
endwhile;
endif;

// Reset Post Data
wp_reset_postdata();

?>

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
WP_Query 的所有参数
WP_Query 是 WordPress 的核心,它支持的参数非常灵活,也非常多,官方的文档也略嫌啰嗦,整理把所有的参数都整理了一遍,以后要使用 WP_Query 只要看这份文档就够了:
Denis
2023/04/15
5440
query_posts函数使用方法小结|wordpress技巧
  query_posts是wordpress非常好用的调用文章函数,可以调用某个分类、标签、日期及作者等不同范围的文章列表。下面随ytkah一起来看看query_posts函数使用方法小结
ytkah
2019/10/24
9920
WordPress JSON REST API简单介绍及使用
这个插件(WordPress JSON REST API (WP API))提供了一个易于使用的REST API,让我们可以通过HTTP获取简单方便的JSON格式的数据,这些数据包括用户,文章,分类等等。获取或更新数据非常简单,只需要发送一个HTTP请求就可以了。
kl博主
2023/11/17
1.4K0
WordPress 查询参数(WordPress Query Vars)完全列表
WordPress 查询参数分公开(Public)和私用(Private),公开就是可以博客链接加入参数就可以查询数据,而私有只能在代码中通过参数传递 WP_Query class。
Denis
2023/04/13
5950
自定义wordpress侧边栏小工具
作者:matrix 被围观: 1,726 次 发布时间:2014-01-25 分类:Wordpress | 4 条评论 »
HHTjim 部落格
2022/09/26
3200
自定义wordpress侧边栏小工具
WordPress自定义查询WP_Query使用方法大全
  自定义调用文章在网站建设中很常用,wordpress也很人性化,用新建查询new WP_Query就能实现相关功能。WP_Query怎么用呢?随ytkah一起来看看吧
ytkah
2019/12/25
4.5K0
CVE-2022-21661:通过 WORDPRESS SQL 注入暴露数据库信息
今年 10 月,我们收到了来自 GiaoHangTietKiem JSC 的 ngocnb 和 khuyenn 的报告,涉及 WordPress 中的 SQL 注入漏洞。该漏洞可能允许攻击者暴露存储在连接数据库中的数据。此漏洞最近被解决为 CVE-2022-21661 ( ZDI-22-220 )。该博客涵盖了该错误的根本原因,并着眼于 WordPress 团队如何选择解决它。首先,这是一个演示该漏洞的快速视频:
Khan安全团队
2022/01/21
4.6K0
史上最详细的WordPress的自定义文章类型指南(1)
最近我发现有很多从google过来的奇怪的关键字,比如best screenshot app 这种,可能是我的这个域名bestscreenshot.com 当时买的有点太随意了。不过这正好也给了我一点灵感,一直以来我自己也算是对各种优秀的工具和软件挺感兴趣的,不管是命令行的还是图形化界面的也都积攒了好多好东西,正好可以在博客上做一点推荐,也可以算作是一种优质内容的补充。
丘壑
2019/04/26
4.5K0
WordPress主题开发,从入门到精通。
相关文档:https://www.wpzhiku.com/document/wordpress-plugin-basics/
房东的狗丶
2023/02/17
10.9K0
【译】WordPress 中的50个过滤器(3):第11-20个过滤器
本文为系列第三篇,原文:50 Filters of WordPress: Filters 11-20 原文地址 不多说,直接进入正题。 本系列文章翻译自tutsplus,原作者为Barış Ünver,翻译人:Jeff,转载请注明原始来源及翻译人,谢谢! 本文若有修正,不会更新于本页,只会更新到Github项目地址上。 在WordPress 中使用可翻译的数据 WordPress 的有一点强大之处就是几乎每一句语言都可以被翻译。如果你的网站语言是英语,你可能就没有这个需求;但其它语系的客户呢? gett
Jeff
2018/01/22
9210
WordPress 技巧:后台文章列表添加自定义分类筛选
如果你的文章或者文章类型添加了自定义分类,下面的代码可以在 WordPress 后台文章列表添加自定义分类下拉筛选框,快速通过自定义分类筛选文章。
Denis
2023/04/13
8360
Simple microblogging [增强版]-WordPress说说插件
* 网站名称:obaby@mars * 网址:https://h4ck.org.cn/ * 本文标题: 《Simple microblogging [增强版]-WordPress说说插件》 * 本文链接:https://h4ck.org.cn/2023/03/simple-microblogging-%e5%a2%9e%e5%bc%ba%e7%89%88/ * 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。
obaby
2023/03/31
5260
Simple microblogging [增强版]-WordPress说说插件
为WordPress添加分页
有的主题只有向前/向后翻页,不能直接点击页码,还不知道有多少页。可是如果你不知道怎么做,只得叹气换主题——你还可以改呀。
gojam
2019/05/14
1.6K0
分享WordPress各种标签大全集合 以及如何调用
wordpress程序日渐成熟,开发者越来越多,各种模版层出不穷,但是想要做一个好的wordpress模版,前提不只是要掌握HTML5前端技术,还必须了解wordpress的各种标签如何调用才可以。今天全百科网就把整理的WordPress各种标签以及是如何调用分享给大家。
于飞云计算
2019/07/22
3.3K0
分享WordPress各种标签大全集合 以及如何调用
WordPress数据库及各表结构
WordPress使用MySQL数据库。作为一个开发者,我们有必要掌握WordPress数据库的基本构造,并在自己的插件或主题中使用他们。
幻影龙王
2021/09/08
3.6K0
wordpress默认css样式class和id集合
  你是否想过如何设计WordPress主题的不同元素?每个主题都不一样,但是有一些CSS的class和id是由WordPress生成的。我们将逐一介绍一些最重要的默认WordPress样式,方便初学
ytkah
2019/07/23
1.1K0
WordPress文章归档页面分组和分页
WordPress 归档页面是一个网站的历史内容存档,它允许用户浏览网站的过去内容。它的存在有以下几个意义:
楚客追梦
2024/08/07
2950
WordPress丨常见函数及拓展模板函数大全
wordpress模板是由PHP语句组成,很多不懂代码的站长都被PHP复杂的代码难倒,难以自己开发个性化的模板。其实想开发一个wordpress模板并不是太难,大家只要了解一些wordpress中的常用函数,即可按照自己的需要进行内容调用了。更高端一点的类似于一些PHP语句的判断等等,这就需要大家自己去学习提高了。本篇文章主要讲解wordpress开发模板中经常需要用到的一些函数。
V站CEO-西顾
2018/06/08
1.9K0
WordPress SEO优化:纯代码添加canonical标签
为网站添加添加canonical标签是SEO优化中非常重要的一步,rrel="canonical"可以解决因网址不同但内容重复,从而造成权重分散的问题,目前百度、Google、雅虎、微软等搜索引擎都已支持此标签。
Yangsh888
2022/08/15
6520
wordpress代码实现相关文章的几种方法
相关文章分类方法主要有根据文章标签以及文章所属分类来进行区分,以下代码分别使用wordpress自带的query_posts()函数以及直接读取数据库来获取文章的相关文章。另附上获取文章作者的其他文章方法。
子润先生
2021/06/24
4980
推荐阅读
相关推荐
WP_Query 的所有参数
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验