- This topic has 9 replies, 2 voices, and was last updated 1 year, 11 months ago by
Elvin.
-
AuthorPosts
-
May 17, 2019 at 1:35 pm #903101
Paul
Hello support team,
I’m just doing some testing on my website: https://www.hearmeraw.uk and if you use the search function, searching for ‘mushrooms’, then many results come up from my online store which is good.
A couple of problems I’m facing though.
1, shortcodes are disabled. Is there any way of enabling them on search results?
2, can the search results have a different layout to that of the blog?
3, is there a way to limit the returned characters of each search result as displaying the entire short description of a product is way too much
4, Could we include meta info or category breadcrubs so people are able to see what section of the site the search result is from.
5, is it possible to exclude certain sections / pages / custom post types from appearing in search results?I love the theme, and I know wordpress’s search function isn’t amazing, and search pages are often over looked in themes, but it would be good to have some options for the search page built into the theme.
Thanks,
PaulMay 17, 2019 at 4:07 pm #903157Tom
Lead DeveloperLead DeveloperHi Paul,
1. I believe the only way to show shortcodes in the results is to enable the full text instead of using an excerpt. The excerpts will strip the shortcodes.
2. What kind of layout are you looking for?
3. You can do this if you use excerpts and not the full text (which would make it so shortcodes don’t show). Let me know which one you want to go with.
4. Do you have these turned off for your archives by default in Customize > Layout > Blog? If so, we can use a function to target the search results and display them.
5. You can use the
pre_get_posts
hook to do that: https://wp-mix.com/wordpress-exclude-custom-post-type-search/Let me know ๐
May 22, 2019 at 5:18 am #907690Paul
Hi Tom,
Thanks for the quick response.
1, The ‘excerpt word count’ does not work on product descriptions. My website is primarily a store, so would be handy to have the exerpts adhere to the excerpt word count.
I believe a good workaround would be to add another section titled ‘Search’ in the ‘Customiser > Layout > Blog > Content’ section, so that people could customise the search page.
2, I’d like to have a column layout for my blog, and have a traditional line by line layout for the search results. Ideally having a small square featured image displayed to the left of the page title and page excerpt.
3, The ‘Excertpt word count’ only works for blogs and not on product descriptions.
4, The meta info, also only shows on blog posts, would be nice to have product categories in the meta info too.
5, thanks.
I’ve also noticed that product featured images do not display on the search results, yet blog featured images do.
Regards,
PaulMay 22, 2019 at 3:03 pm #908262Tom
Lead DeveloperLead DeveloperHey Paul,
1. This might help: https://stackoverflow.com/questions/35693954/woocommerce-short-description-excerpt-length
2. So do you have the column layout already set up for your regular archives? If so, try this function:
add_filter( 'option_generate_blog_settings', function( $settings ) { if ( is_search() ) { $settings['column_layout'] = false; $settings['page_post_image_alignment'] = 'left'; } return $settings; } );
4. I wonder if something like this would do it?:
add_action( 'generate_after_content', function() { if ( is_search() && 'product' == get_post_type() ) { foreach ( get_the_terms( get_the_ID(), 'product_cat' ) as $cat ) { echo $cat->name; } } } );
May 23, 2019 at 12:24 am #908469Paul
Thanks Tom,
1, unfortunately, code doesn’t work on the search page when results are returned…?
2, Perfect. Thanks
4, Thanks. I’ll maybe look to edit the search.php and put into the child theme for more customisations.
Are there any plans for future releases to improve the search results page?
Thanks,
PaulMay 23, 2019 at 7:04 am #908845Tom
Lead DeveloperLead DeveloperYour search results page seems to be one column, although there aren’t any featured images to align left. Have you made any adjustments to include products in the search?: https://docs.generatepress.com/article/generate_navigation_search_output/#woocommerce-products
April 9, 2020 at 12:47 am #1232143Maik
Hello,
im experiencing the same Issues with Shortcodes in Search Results, they were not shown.
Any workaround how to fix that?
Best regards
April 9, 2020 at 9:33 am #1232884Tom
Lead DeveloperLead DeveloperHi there,
You need to display the full content in search results to show shortcodes:
add_filter( 'generate_show_excerpt', function( $show ) { if ( is_search() ) { return false; } return $show; } );
June 27, 2021 at 5:04 am #1836323Marie Amandine
Hello support team,
I am using the pre_get_posts. When I add ‘product’, tags and categories ‘post’ type disappear.
function shapeSpace_filter_search($query) { if (!$query->is_admin && $query->is_search) { $query->set('post_type', array('post', 'product')); } return $query; } add_filter('pre_get_posts', 'shapeSpace_filter_search');
Any idea ?
June 27, 2021 at 5:22 pm #1836876Elvin
StaffCustomer SupportHi Marie,
Can you open a new topic for this? This topic is already marked solved.
Please include more details on the new topic as well. (expected result, current state.)
Let us know. ๐
-
AuthorPosts
- You must be logged in to reply to this topic.