وردپرس نسخه 3,0+مرجع توابع مورد استفاده در کد نویسی پوسته
Query Tags
Get Postsget_posts();
This is a simple tag for creating multiple loops.
<?php get_posts('arguments'); ?>
$numberposts
Integer
(Optional) Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit. Default: 5.
$offset
Integer
(Optional) Offset from latest post. Default: 0.
$category
Integer
(Optional) Only show posts from this category ID. Making the category ID negative (-3 rather than 3) will show results not matching that category ID. Multiple category IDs can be specified by separating the category IDs with commas - but an array of IDs does not work. Default: none.
$category_name
String
(Optional) Only show posts from this category name or category slug. Default: none.
$tag
String
(Optional) Only show posts with this tag slug. If you specify multiple tag slugs separated by commas, all results matching any tag will be returned. If you specify multiple tag slugs separated by spaces, the results will match all the specified tag slugs. Default: none.
$orderby
String
(Optional) Sort posts by one of various values (separated by space), including:
- 'author' - Sort by the numeric author IDs.
- 'category' - Sort by the numeric category IDs.
- 'content' - Sort by content.
- 'date' - Sort by creation date.
- 'ID' - Sort by numeric post ID.
- 'menu_order' - Sort by the menu order. Only useful with pages and attachments.
- 'mime_type' - Sort by MIME type. Only useful with attachments.
- 'modified' - Sort by last modified date.
- 'name' - Sort by stub.
- 'parent' - Sort by parent ID.
- 'password' - Sort by password.
- 'rand' - Randomly sort results.
- 'status' - Sort by status.
- 'title' - Sort by title.
- 'type' - Sort by type.
Notes: Sorting by ID and rand is only available starting with Version 2.5. Default: post_date.
$order
String
(Optional) How to sort $orderby. Valid values:
- 'ASC' - Ascending (lowest to highest)
- 'DESC' - Descending (highest to lowest) - Default
$include
String
(Optional) The IDs of the posts you want to show, separated by commas and/or spaces. The following value would work in showing these six posts: '45,63, 78 94 ,128 , 140'. Note: Using this parameter will override the numberposts, offset, category, exclude, meta_key, meta_value, and post_parent parameters. Default: none.
$exclude
String
(Optional) The IDs of any posts you want to exclude, separated by commas and/or spaces (see $include parameter). Default: none.
$meta_key and $meta_value
String
(Optional) Only show posts that contain a meta (custom) field with this key and value. Both parameters must be defined, or neither will work. Default: none.
$post_type
String
(Optional) The type of post to show. Available options are:
- post - Default
- page
- attachment
- any - all post types
$post_status
String
(Optional) Show posts with a particular status. Multiple statuses can be given, separated with a comma. Available options are:
- publish - Default
- private
- draft
- future
- inherit - Default if $post_type is set to attachment
- (blank) - all statuses (use 'any' instead of blank in 3.0, not sure when it changed)
$post_parent
Integer
(Optional) Show only the children of the post with this ID. Default: none.
$nopaging
Boolean
(Optional) Enable or disable paging. If paging is disabled, the $numberposts option is ignored. Default: none.
WP Reset Querywp_reset_query();
This function destroys the previous query used on a custom Loop. Function should be called after The Loop to ensure conditional tags work as expected.
<?php wp_reset_query(); ?>
No parameters.