[Resolved] remove the meta from search results

Home Forums Support remove the meta from search results

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1518098
    Josh

    How can I remove the “date BY author” from the search results page?

    Also, is there any way to add my custom post to the search results?

    #1518287
    Elvin
    Staff
    Customer Support

    Hi,

    Also, is there any way to add my custom post to the search results?

    To clarify: Do you mean, you want to use a custom post list plugin to display search results?

    How can I remove the “date BY author” from the search results page?

    Can you link us to the site in question? We should be able to prevent it from displaying w/ custom CSS.

    You can provide the site details on the Private Information text area. Thank you.

    A wise man once said:
    "Have you cleared your cache?"

    #1518303
    Josh

    I created my own CPT with no plugin.

    My custom post type does show up, but i guess I was hoping that it could return results by post type.

    example
    posts
    1
    2
    2
    Pages
    1
    2
    Products
    1
    2

    Site details below.

    #1518320
    Elvin
    Staff
    Customer Support

    Oh right that makes sense. By default, WordPress doesn’t include custom post types in its search result.

    For starters let’s try making your search result include your custom post type by adding this PHP snippet:

    function include_cpt_search( $query ) {
        if ( $query->is_search ) {
    		$query->set( 'post_type', array( 'post', 'page', 'custom_post_type' ) );
        }
        return $query;
    }
    add_filter( 'pre_get_posts', 'include_cpt_search' );

    Simply add your custom post type inside the $query->set post_type array().
    Reference: https://www.dhirenpatel.me/include-custom-post-type-wordpress-search-result/#:~:text=In%20the%20WordPress%20default%20search,third%20party%20free%20WordPress%20plugin.

    As for separating posts results by post type, perhaps this can help:
    https://wordpress.stackexchange.com/posts/181807/revisions

    Here’s how to add PHP snippets.:
    https://docs.generatepress.com/article/adding-php/

    A wise man once said:
    "Have you cleared your cache?"

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