Customise search results page

Hi, how do I customise my search results page template? I couldn’t find an answer on the forum except one post where it says the theme doesn’t have a search results page. My results page is currently a bunch of text from the page/post content, the header, footer and page navigation buttons.

Hello @9metis,

Thanks for writing in!

I have checked your site and the search results does not display any titles. Did you have any custom templates in your child theme? You may have remove the titles because it is not displaying them. We’d love to check your child theme and see what customizations did you made to the template files. If you could give us access to your site that would be great. Please create a secure note and insert your WP credentials when you reply. To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Regards.

Hey @9metis,

The issue was caused by your customization of content.php which is part of the output of the search results. Please remove it from your child theme’s framework/views/icon folder.

If you wish to continue customizing the said template, please consult with a third-party WordPress developer so you could work closely to achieve your specific requirements and he/she could fix customization issues.

The Search Results page is powered by _index.php which is located in \framework\views\global folder of the parent theme. If you open that file, you’ll see that content.php is part of the output using the x_get_view function. You’ll also see in that file the is_search() function which is the WordPress Conditional Tag to check if the page is a search results page.

With that knowledge combined with our Customization Best Practices guide you’ll be able to customize the search results page to your liking.

Please just note that we do not support fixing and enhancing issues resulting from customizations.

Hope that helps and thank you for understanding.

Ok thanks that was a great help!

You’re always welcome!

Cheers.

Hi again,

I have done what you suggested above but my code is not exactly working.

I uploaded the _index.php file to my child theme folder with the below change (content to searchpage).

<?php else : ?>

  <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
      <?php x_get_view( $stack, 'searchpage', get_post_format() ); ?>
    <?php endwhile; ?>
  <?php else : ?>
    <?php x_get_view( 'global', '_content-none' ); ?>
  <?php endif; ?>

I then created a new file called searchpage.php with the below code and uploaded that to \framework\views\icon.

 <?php

// =============================================================================
// VIEWS/ICON/SEARCHPAGE.PHP
// -----------------------------------------------------------------------------
// Search page results for icon.
// =============================================================================

?>


<?php get_header(); ?>
    <div class="search-container">
    <section id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
        <!-- <div class="search-page-form" id="ss-search-page-form"><?php get_search_form(); ?></div> -->
 
        <?php if ( have_posts() ) : ?>
 
            <header class="page-header">
                <span class="search-page-title"><?php printf( esc_html__( 'Search Results for: %s'), '<span>' . get_search_query() . '</span>' ); ?></span>
            </header><!-- .page-header -->
 
            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
            <span class="search-post-title"><?php the_title(); ?></span>
            <span class="search-post-excerpt"><?php the_excerpt(); ?></span>
            <span class="search-post-link"><a href="<?php the_permalink(); ?>"><?php the_permalink(); ?></a></span>
 
            <?php endwhile; ?>
 
            <?php //the_posts_navigation(); ?>
 
        <?php else : ?>
 
            <?php //get_template_part( 'template-parts/content', 'none' ); ?>
 
        <?php endif; ?>
 
        </main><!-- #main -->
    </section><!-- #primary -->
</div>
<?php //get_sidebar(); ?>
<?php get_footer(); ?>

The same results gets repeated after the footer. I’ve tried similar other code and they all have the same issue. I even added the below to my child theme’s functions.php:

add_filter('cornerstone_enable_search', '_returnfalse');

Am I missing something?

Hello @9metis,

Please renamed searchpage.php into just search.php and then relocate it to your child theme’s folder.

wp-content/themes/x-child/search.php

Please let us know how it goes.

Thanks, this worked!!

We’re glad it worked.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.