Site logo

Archived topic

Search results influenced by blog archive setting

10 replies · Started by Margot on March 15, 2018

Viewing posts 1–11 of 11

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!

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?

$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;
}

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?

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.

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.

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

That's it!! Thank you so much!

No problem!

This archived topic is closed to new replies.