Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

primary menu search function

Home / Forums / Virtue Theme / primary menu search function

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
November 14, 2015 at 3:18 am

Hello I’m really stuck on trying to customise the search filter that appears in the primary menu.

I have created a child functions file and added the following code:

add_filter(‘posts_orderby’,’my_sort_custom’,10,2);
function my_sort_custom( $orderby, $query ){
global $wpdb;

if(!is_admin() && is_search())
$orderby = $wpdb->prefix.”posts.post_type ASC, {$wpdb->prefix}posts.post_date DESC”;

return $orderby;
}

It’s not working as I need it to though. I need it to order the types in the following order:

1) products
2) blog posts
3) everything else

Obviously in the post.type DESC it wont achieve what I need as Testimonials, Products, Posts, Pages. With ASC it’s Pages, Posts, Products and Testimonials.

Is there anyway I can target specific post.types and order them?

Any help would be greatly appreciated.

Thank you

Tom

  • The forum ‘Virtue Theme’ is closed to new topics and replies.