Archived topic
different design for search results page
7 replies · Started by Martin on October 24, 2021
Hi,
I added the following code in php but the my search results page looks exactly the same.
Especially the ugly white block at at the top. How can I design this one?
best regards
Martin
add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' );
function lh_custom_search_results_page_settings( $options ) {
if ( is_search() ) {
$options['read_more_button'] = true;
$options['date'] = false;
$options['categories'] = false;
$options['tags'] = false;
$options['comments'] = false;
$options['infinite_scroll'] = true;
$options['infinite_scroll_button'] = true;
$options['masonry_load_more'] = 'More search results';
$options['post_image'] = true;
$options['post_image_position'] = 'post-image-above-header';
$options['post_image_alignment'] = 'post-image-aligned-center';
$options['column_layout'] = false;
$options['featured_column'] = true;
$options['masonry'] = false;
}
return $options;
}
Hi there,
Sorry but not sure if I fully understand.
Are you trying to remove the search result title here?
https://www.screencast.com/t/yjWYTNWdr
That element is unrelated to the snippet you are using.
Let me know :)
No but I would like to apply CSS to it. Like rounded borders or clear background with white text color.
However the filter I applied should Style how the actual results are displayed. I got this from another help post.
Did I get this wrong?
best regards
martin
Hi there,
that PHP Snippet overwrites your Customizer > Layout > Blog settings on the Search page.
If you want the search results to match the Blog then first remove that Snippet.
Then let us know.
Hi David,
that was the reason why I added it in the first place. I want the search page to have a different layout with publish date added and so on. However adding the snippet did nothing at all.
I deactivated the Snippet now and cleared the cache.
I'd love to have the search page results more compact with smaller headline size, publish date and category. I hoped the Snippet would do that for me.
best regards
Martin
Simplest way is to use a Block Element - Content Template:
https://docs.generatepress.com/article/block-element-content-template/
You can design it yourself and just set the Display Rule Location to Search Results
Awesome! didn't know that!
Will give it a go.
best regards
Martin
You're welcome :) Have fun!