Hi
I would like to set Featured as default sort and found this
Sort by featured
/** * Set to show ‘Featured’ first. * * @param WP_Query Object $wp_obj * @return WP_Query Object $wp_obj */ function _custom_sort($wp_obj){ $wp_obj->set(‘meta_key’, ‘featured’); $wp_obj->set(‘orderby’, ‘DESC’); return $wp_obj; } add_filter( ‘pre_get_posts’, ‘_custom_sort’);
But if I use this code, only the featured entries are shown
This reply is for PremiumPress customers only.
292
Views
1
Replies
Copyright © 2010-2024 PremiumPress Limited.
Hi
I would like to set Featured as default sort and found this
/**
* Set to show ‘Featured’ first.
*
* @param WP_Query Object $wp_obj
* @return WP_Query Object $wp_obj
*/
function _custom_sort($wp_obj){
$wp_obj->set(‘meta_key’, ‘featured’);
$wp_obj->set(‘orderby’, ‘DESC’);
return $wp_obj;
}
add_filter( ‘pre_get_posts’, ‘_custom_sort’);
But if I use this code, only the featured entries are shown
Members Only Content
This reply is for PremiumPress customers only.
Login Now