开发者 | hijiri |
---|---|
更新时间 | 2023年12月21日 09:53 |
捐献地址: | 去捐款 |
PHP版本: | 3.5.0 及以上 |
WordPress版本: | 6.4.2 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
/wp-content/plugins/
directory.Sub query
By using the 'WP_Query', you can re-override the parameters.
WP_Query
`
'ID',
'order' => 'DESC',
) ) ?>
`
get_posts()
`
'title',
) ) ?>
`
ATTENTION: Only if you use 'get_posts()' to re-overwrite to the default order( orderby=date, order=DESC ), You need to use own custom parameter 'orderby=default_date'.
`
'default_date',
'order' => 'DESC',
) ) ?>
`
Main query
By using the 'pre_get_posts' action hook or 'query_posts()', you can re-override the parameters.
pre_get_posts
function my_filter( $query ) { if ( is_admin() || !$query->is_main_query() ) return; if ( is_home() ) { $query->set( 'orderby', 'date' ); $query->set( 'order', 'DESC' ); return; } } add_action( 'pre_get_posts', 'my_filter' );
query_posts()
`
'rand'
) ); ?>
`
Go to "screen options" and change "Number of items per page:".