Search result page customization

There are tons of post and request in this forum about this specific “search results” page customization but never an answer or any walkthrough or recipe to make this happen.

Most of the clients of X are not developers and to custom-create php pages is very difficult and/or not possible. X together with Cornerstone provide great tools to fast page building but this specific module never completed.

Questions:

  1. The X theme upgrade with Pro give any solution with this problem?
  2. Anybody ever has accomplished X theme custom search result page?
    (example: 3column layout with no sidebar, standard pagination)

Any help would be greatly appreciated,
Nick

1 Like

Hi There,

Thanks for writing in! There are various alternative methods to customize your search results page. Could you please try adding the following CSS rules into your Theme Options > Global CSS rules and then you should be able to improve it from there.

.search-results .x-sidebar.right {
    display: none;
}
.search-results .x-main.left {
    width: 100%;
}
.search-results .x-main.left article {
    width: 30%;
    float: left;
    margin-right: 1%;
}

Hope that helps.

1 Like

Hi, thank you for your quick help with css.

But is change the woocommerce product search results as well.
The main goal is to create different search result page for the blog search (3column, sidebar, masonry) and for product search result (3column, with sidebar, no masonry).

Unfortunately seems the search results page for these 2 is the same with the only difference the archive class on the body tag.

Is there any way to work this out somehow?
Thank you,
Nick

Hello Nick,

Your results page as of this moment is display contrary to what you wanted. The search result page for the blog search is in 3column, sidebar, no masonry and for product search result is in 3column, with sidebar, masonry.

You can still use the code if you want to by adding :not(.woocommerce) in the selector.
For example:

/* this works for all search pages */
.search-results .x-main.left {
    // your styling here
}

.search-results:not(.woocommerce) .x-main.left {
    // your styling here
}

/* this will only work for product search page */
.search-results.woocommerce .x-main.left {
    // your styling here
}

Hope this helps.

What exactly would one put here? For instance to get a masonry layout?

Hello There,

Thanks for updating in!

Masonry layout is using a JS script and not a css code. If you want to display masonry, you will have to modify the theme files itself so that the JS can be trigger. Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

Once you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/GLOBAL/_INDEX.PHP
// -----------------------------------------------------------------------------
// Includes the index output.
// =============================================================================

$stack = x_get_stack();

if ( is_home() ) :
  $style     = x_get_option( 'x_blog_style' );
  $cols      = x_get_option( 'x_blog_masonry_columns' );
  $condition = is_home() && $style == 'masonry';
elseif ( is_archive() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_archive() && $style == 'masonry';
elseif ( is_search() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_search() && $style == 'masonry';
endif;

?>

<?php if ( $condition ) : ?>

  <?php x_get_view( 'global', '_script', 'isotope-index' ); ?>

  <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">

    <?php if ( have_posts() ) : ?>
      <?php while ( have_posts() ) : the_post(); ?>
        <?php if ( $stack != 'ethos' ) : ?>
          <?php x_get_view( $stack, 'content', get_post_format() ); ?>
        <?php else : ?>
          <?php x_ethos_entry_cover( 'main-content' ); ?>
        <?php endif; ?>
      <?php endwhile; ?>
    <?php else : ?>
      <?php x_get_view( 'global', '_content-none' ); ?>
    <?php endif; ?>

  </div>

<?php else : ?>

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

<?php endif; ?>

<?php pagenavi(); ?>

3] Save the file named as _index.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/global/ or wp-content/themes/pro-child/framework/views/global/ if you are using Pro theme.

Hope this helps.

I have you up until I get to the folder…there is not a subfolder /global/ in the child theme.
Should I create?
Thank you so very much for all your help btw!

Hey There,

In the child theme, those folder path does not exist yet. You will have to create it and place the file in the correct folder path or else, it will not work.

Hope this helps.

1 Like

And to get columns or masonry look?

I uploaded the file…as described…but am still not getting the columns/masonry look? Ideas?

https://julielohre.com/?s=julie

Hello There,

​To assist you better with this issue, would you mind providing us the url of your site with login credentials so we can take a closer look? This is to ensure that we can provide you with a tailored answer to your situation.

To do this, you can create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

Thank you.

Here are login info and link

Hi there,

I can verify that it’s implemented, but I couldn’t apply some changes since the file isn’t writable through admin.

Would you mind providing your FTP login credentials as well? For the meantime, please change this code block

elseif ( is_search() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_search() && $style == 'masonry';
endif;

to this

elseif ( is_search() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = 4;
  $condition = is_search();
endif;

Thanks!

Will change the code block.
Also…updated the private note above with FTP Login info…
Thanks so much for your help.
Cheers,
Rick

Hello Rick,

Everything is in place. Your search page is already in masonry layout.

If you need anything else we can help you with, don’t hesitate to open another thread.

Ok, silly question. How to get it to be a grid layout vs cascading masonry? Possible?

That’s not currently possible since the current styling is only limited to that. Thanks!

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