HTML stripped from search results page

Home Forums Product Support Forums Ajax Search Pro for WordPress Support HTML stripped from search results page

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #22951

    Hello 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

    Ernest Marcinko
    Ernest Marcinko

    Hi 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.

    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.