New Landing How can we help? Themeforest Theme Support Dante Hide Clients results

Viewing 6 posts - 1 through 6 (of 6 total)
  • Posted in: Dante
  • #117324
    alemarengo
    Member
    Post count: 695

    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.

    #117368
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    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
    Mohammad

    #117383
    alemarengo
    Member
    Post count: 695

    Ok, 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.

    #117451
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    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
    Mohammad

    #117457
    alemarengo
    Member
    Post count: 695

    Many thanks to you Mohammad!!!!!!!!!!!!!!!!!!

    #117488
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You most welcome.
    Thanks
    Mohammad

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register