Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › HTML stripped from search results page
- This topic has 1 reply, 2 voices, and was last updated 7 years ago by
Ernest Marcinko.
-
AuthorPosts
-
May 29, 2019 at 10:11 pm #22951
timburkart
ParticipantHello Ernest,
I have a problem where HTML is being stripped from from the search results output. The code below has been added to my theme’s functions.php file and works on another site where your plugin is not installed. That leads me to believe the problem lies with Ajax Search Pro. I need your assistance please.
add_action( 'pre_get_posts', 'modify_search_results' ); function modify_search_results( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $query->set( 'posts_per_page', '25' ); $query->set( 'post_type', array( 'article', 'source', 'author' ) ); add_filter( 'the_content', 'custom_field_content' ); } return $query; } function custom_field_content( $content ) { $source = '<p class="source-type">' . genesis_get_custom_field( 'source_type' ) . '</p>'; $author = '<p class="gmo-author">' . genesis_get_custom_field( 'author' ) . '</p>'; $article = '<p class="gmo-article">' . genesis_get_custom_field( 'gmo_article' ) . '</p>'; $output = ''; $output .= wpautop( $source ); $output .= wpautop( $author ); $output .= wpautop( $article ); $output .= wpautop( $content ); return $output; }To see what I mean go to the url provided. The site is password protected. Use the password “hellothere” without quotes. Then click on the Explore by Keyword menu option and select any keyword. I have been testing with the keyword Glyphosate. You will see the results. They data is being returned however the p tags which should delimit each data element is missing.
I appreciate your assistance and look forward to your reply.
Thank you!
Tim Burkart
May 30, 2019 at 9:22 am #22955Ernest Marcinko
KeymasterHi Tim,
I’m afraid this is not related to the plugin, as it should not have any effect on the results page layout. Many themes display the post excerpts within the results pages, not the full content, and often the excerpts are stripped from additional html tags. I suggest checking the search.php file in the theme directory to see how exactly it is processed. There might be options as well somewhere in the theme settings that may let you change the search results display, I am not sure.
-
AuthorPosts
- You must be logged in to reply to this topic.