Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Search on my website

  • Hi there,

    How could I add a search engine on my website? Where you can setup which page can looking for?

    I means, I will have a lens icon where the user could looking for content.

  • Hi there,

    go to Customizer > Layout > Primary Navigation and there is an option to activate the Navigation Search.

  • Thanks,

    How can I configure the navigation search to search only pages and forums?

  • Try this PHP snippet, and replace forums with the actual CPT slug:

    function search_filter($query) {
        if ($query->is_search && !is_admin()) {
            $query->set('post_type', array( 'page','forums'));
    	$query->set('orderby', 'type');
            $query->set('order', 'ASC');
    		
        }
        return $query;
    }
    
    add_filter('pre_get_posts','search_filter');

    Adding PHP: https://docs.generatepress.com/article/adding-php/

  • Hi, how can I disable the navigation search on the homepage?
    I am only interested in the navigation search that appears on the subscriber page.

    (Attached a screenshot)
    https://postimg.cc/pp1z4tnd

  • Hi there,

    add this CSS to your site:

    
    .home [data-gpmodal-trigger="gp-search"] {
        display: none;
    }
    
  • Thank you, and how could I hide it also on the “lista-de-espera” page and on the “Contact” page?

    Because the search icon appears on the following pages
    http://www.midominio.com/lista-de-espera
    http://www.midominio.com/contact

  • Those two links are returning Not Found ?

  • Exactly,
    In the private information I write you my domain and the pages.

  • Change the CSS to:

    :is(.page-id-3512,.page-id-4003, .home) [data-gpmodal-trigger="gp-search"] {
        display: none;
    }
  • Hi Yin, Regards to this code

    https://generate.support/topic/search-on-my-website/#post-87074
    replace forums with the actual CPT slug

    function search_filter($query) {
        if ($query->is_search && !is_admin()) {
            $query->set('post_type', array( 'page','forums'));
    	$query->set('orderby', 'date');
            $query->set('order', 'ASC');
    		
        }
        return $query;
    }
    
    add_filter('pre_get_posts','search_filter');

    What would be the CPT slug of a forum?

  • I don’t know, can you link me to a forum post type on your site?

  • Ok, in the private information you have a link to a FORUM and DEBATE

  • I think the post type is just forum, so change forums to forum.

  • Hi, I have this code:

    function search_filter( $query ) {
        if ($query->is_search && !is_admin()) {
             $query->set('post_type', array('post','forum'));
    		 $query->set('category_name','my-ia');
    		 $query->set('orderby', 'date');
             $query->set('order', 'ASC');
        }
    }
    add_filter('pre_get_posts', 'search_filter', 10, 2);

    The search is correct, I can search for articles (post) but the problem is that I can’t search for a forum answer like search the word “type specimen book”. How can do it?

    I attached URL of the forum in the private information.

  • Just so you know pre_get_post is a WP function, it’s not GP specific, if this code doesn’t work, please reach out to the forum plugin’s support.

Viewing 16 posts - 1 through 16 (of 18 total)
  • You must be logged in to reply to this topic.