Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Resolved] Search results influenced by blog archive setting

Home Forums Support [Resolved] Search results influenced by blog archive setting

Home Forums Support Search results influenced by blog archive setting

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #520954
    Margot

    I looked around on the forum and didn’t seem to find an answer to this so here goes. I have been customizing my blog archive page but I noticed that all the changes I make to that on the customizer then modifies the outcome of my search results page. Basically, I set my blog archive page to have two columns and to hide the page excerpts and meta/tags but I want my search results page to be all in one column and to include the page excerpts.

    Do I have to create a separate page template for the search results page in order to do this? I’ve been hiding the excerpts this way because if I set the excerpt to 0 on the customizer it leaves me with an ellipsis (“…”) :

    .generate-columns-container .inside-article .entry-summary p:nth-child(1){
    	display:none!important;
    }

    Thanks!

    GP Premium 1.5.6
    #521128
    Leo
    Staff
    Customer Support
    #521660
    Margot

    Thanks for that! I was able to do the single column layout no problem.

    I need a little help understanding how to do the opposite so to specifically hide the excerpt from the archive page though. I figured since most of the pages require the excerpt and the only one that would be hiding it would be the blog archive page, I think that’s probably the one that needs to be dealt with and not vide versa? Does $hide_excerpt do the opposite of $show_excerpt?

    #521953
    Leo
    Staff
    Customer Support

    $show_excerpt just returns the setting you set the in the customizer.

    Try this snippet:

    add_filter( 'generate_show_excerpt','lh_blog_hide_excerpt' );
    function lh_blog_hide_excerpt( $show_excerpt )
    {
        if ( is_home() )
    		return false;
    	
    	return $show_excerpt;
    }
    #522035
    Margot

    Ahh I see! Yes!! That seems to work except it eliminates the “read more” button that I still want to have there even if the excerpt is not. Is that even possible?

    #522040
    Margot

    You know what, I checked again and I was wrong, the snippet didn’t work. It looked like it just expanded all the posts and revealed the entire post and content for each.

    #522104
    Leo
    Staff
    Customer Support

    Actually try this instead:

    add_filter( 'excerpt_length','lh_custom_excerpt_length', 1000 );
    function lh_custom_excerpt_length( $length ) 
    {
        if ( is_home() ) {
            return 0;
        } else {
            return $length;
        }
    }

    Make sure excerpt it turned on in the customizer.

    #522299
    Margot

    Thanks Leo! That worked! Is it possible to remove the […] or is that not possible?

    #522449
    Leo
    Staff
    Customer Support

    Hmm try this CSS:

    .blog .entry-summary p:not(.read-more-container) {
        display: none;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    #522543
    Margot

    That’s it!! Thank you so much!

    #522685
    Leo
    Staff
    Customer Support
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.