Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress query orderby name

query_posts( array( 
    'post_type'      => 'page',
    'posts_per_page' => -1,
    'orderby'        => 'title',
    'order'          => 'ASC'
) );
Comment

orderby wordpress options

// WP_Query orderby

orderby (string | array) – Sort retrieved posts by parameter. Defaults to ‘date (post_date)’. One or more options can be passed.
‘none‘ – No order (available since version 2.8).
‘ID‘ – Order by post id. Note the capitalization.
‘author‘ – Order by author.
‘title‘ – Order by title.
‘name‘ – Order by post name (post slug).
‘type‘ – Order by post type (available since version 4.0).
‘date‘ – Order by date.
‘modified‘ – Order by last modified date.
‘parent‘ – Order by post/page parent id.
‘rand‘ – Random order.
‘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. You may also specify ‘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.
Comment

PREVIOUS NEXT
Code Example
Php :: laravel session forget 
Php :: php bbcode tag dellete 
Php :: php subtract mins to datetime 
Php :: witherrors laravel 
Php :: searching and removing element from an array php 
Php :: intl extension php ubuntu 
Php :: php time format 
Php :: get contents of a tmp file php 
Php :: docx file validation laravel 8 
Php :: wp-config.php define home page 
Php :: php get class name of this 
Php :: laravel order by 
Php :: php echo and array to consle 
Php :: repeater acf 
Php :: wordpress get current category slug 
Php :: Print exact sql statement executed 
Php :: laravel eloquent order by alphabetical order 
Php :: Internal error: xmlSchemaXPathProcessHistory, The state object to be removed is not the first in the list. 
Php :: laravel make migration update table 
Php :: validate timestamp php 
Php :: form_dropdown codeigniter from database is assocative array 
Php :: convert stdclass to json in php 
Php :: laravel create model with migration and resource controller 
Php :: php counting number of chars excluding newlines 
Php :: check network connection php 
Php :: how login one user with id in laravel 
Php :: get first 200 characters string php 
Php :: install symfony ubuntu 
Php :: laravel sentence word count 
Php :: encryp with codeigniter 3 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =