Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Hide Clients results
New Landing › How can we help? › Themeforest Theme Support › Dante › Hide Clients results
- This topic has 5 replies, 2 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Dante
-
October 5, 2014 at 4:15 pm #117324
Hi.
I’d like to exclude Clients from search results. Everywhere. Even in the search preview, usually next to main menu.
I know there was a topic like this. It’s closed.
I added this to functions.php, but unsuccessfully:function searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set('post_type',array('post','page','product')); } return $query; } add_filter('pre_get_posts','searchfilter');
My need bears from the fact that I set a woocommerce store and, instead of Clients, I have to deal with Manufacturers or Brands whose products I have to sell.
So, since I don’t think you’re going to add another post type, I have to find a workaround for it.
I simply have to hide Clients from everywhere in the theme, EXCEPT FOR a clients carousel I need to show my ecommerce brands.
I hope I explained well. 🙂Can you help me with that?
Thanks.October 6, 2014 at 6:19 am #117368Hi,
Please open to edit clients-type.php at /dante/swift-framework/custom-post-types/Find this code:- $args = array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => false, 'menu_icon'=> 'dashicons-businessman', 'rewrite' => false, 'supports' => array('title', 'thumbnail'), 'has_archive' => true, 'taxonomies' => array('clients-category', 'post_tag') ); Change to :- $args = array( 'exclude_from_search' => true, // the important line here! 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => false, 'menu_icon'=> 'dashicons-businessman', 'rewrite' => false, 'supports' => array('title', 'thumbnail'), 'has_archive' => true, 'taxonomies' => array('clients-category', 'post_tag') );
Thanks
MohammadOctober 6, 2014 at 7:02 am #117383Ok, it works.
Many many thanks.
The only thing that worries me is how to prevent this modification NOT to be changed with the next major update. I created the same folder root within dante-child’s one, but unsuccefully.
May I copy the entire function in functions.php?
Will it work?
Thank for your reply.October 6, 2014 at 8:56 am #117451Hi,
Please use this code at functions.php of child theme:-remove_action( 'init', 'clients_register', 20 ); add_action('init', 'clients_register_new'); function clients_register_new() { $labels = array( 'name' => __('Clients', "swift-framework-admin"), 'singular_name' => __('Client', "swift-framework-admin"), 'add_new' => __('Add New', "swift-framework-admin"), 'add_new_item' => __('Add New Client', "swift-framework-admin"), 'edit_item' => __('Edit Client', "swift-framework-admin"), 'new_item' => __('New Client', "swift-framework-admin"), 'view_item' => __('View Client', "swift-framework-admin"), 'search_items' => __('Search Clients', "swift-framework-admin"), 'not_found' => __('No clients have been added yet', "swift-framework-admin"), 'not_found_in_trash' => __('Nothing found in Trash', "swift-framework-admin"), 'parent_item_colon' => '' ); $args = array( 'exclude_from_search' => true, // the important line here! 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => false, 'menu_icon'=> 'dashicons-businessman', 'rewrite' => false, 'supports' => array('title', 'thumbnail'), 'has_archive' => true, 'taxonomies' => array('clients-category', 'post_tag') ); register_post_type( 'clients' , $args ); }
Thanks
MohammadOctober 6, 2014 at 9:01 am #117457Many thanks to you Mohammad!!!!!!!!!!!!!!!!!!
October 6, 2014 at 9:50 am #117488Hi,
You most welcome.
Thanks
Mohammad -
Posted in: Dante
You must be logged in and have valid license to reply to this topic.