Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #614506

    MrK
    Participant

    Hi guys I’m using this nice plugin to filter search results: https://wordpress.org/plugins/search-filter/

    This are the instruction to setup the search page:

    1) Take a template from your theme that you wish to use for displaying results – for Avada I would take search.php (its up to you which template from your theme to use), and then duplicate your template to search-filter.php.

    2) In S&F, under “display results” you will need to tick use custom template and then set the filename to search-filter.php.

    Now we have S&F displaying your results using a copy of your template – this will still not work as we need to make some modifications – but at least we are telling S&F which template to use.

    3) Remove any custom queries in the new template (search-filter.php) – its the queries within the template files that are usually the cause of the problem – all you will hopefully need to do is comment out or remove the lines with the queries on. Take a look for any instances of WP_Query, get_posts or query_posts and remove these. In Avada (at the time of writing) this would be line 71, remove the whole line:

    query_posts($query_string.’&posts_per_page=’.$smof_data[‘search_results_per_page’].’&paged=’.$page_num);

    And that’s it – the basics covered and will work for 90% of themes out there!

    Can you point me to the search loop page your theme is using?

    thanks

    #614578

    Jack
    Keymaster

    Hi there @mrk,

    Hope you’re well today and thanks for your question.

    In X, the template that outputs the search results is _index.php in /framework/views/global.

    Hope this helps. 🙂

    Thanks!

    #614588

    MrK
    Participant

    Yes guys thanks,
    can I also make the search results look like masonry like the archive page? 3 column masonry.

    And also how can I put it on my child theme? simply adding nested folders like framework/global/ and put the new file there?

    thanks

    #614645

    Zeshan
    Member

    Hi there,

    Regretfully, masonry laynot is not available for search results page. It could be possible to achieve with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.

    In regard to the child theme, yes, you can simply copy the file from your parent theme to the same level of directory in the child theme. So for example, if the file is located in wp-content/themes/x/framework/views/global/, you can copy it in your child theme’s folder /framework/views/global/.

    Thanks!

    #614646

    MrK
    Participant

    thanks guys

    #614708

    Zeshan
    Member

    You’re welcome! 🙂

    #614728

    MrK
    Participant

    Sorry forgot: can you point me to the results php page to edit in order to have masonry?

    #614759

    Zeshan
    Member

    Hi there,

    X uses the same file index.php for all archives including search results page. You can copy it or create your own search template page: https://codex.wordpress.org/Creating_a_Search_Page

    Thanks!

    #614788

    MrK
    Participant

    thanks guys so why when I get to search result I see an url like: mydomain.com/?sfid=1807

    #614836

    Paul R
    Moderator

    Hi,

    That is a default behaviour of your third party plugin.

    Please refer to the link below

    https://www.designsandcode.com/forums/topic/how-to-hide-the-url-after-search-for-product-or-change-it-by-some-random-id/

    Thanks

    #617788

    MrK
    Participant

    Hi guys now plugin is working very well thanks.

    As I want to edit the search results layout (shows 1 column I would like to have the same masonry 3 column style I use for categories layout) which is the file I have to edit?

    What I did was I moved the _index.php as you said from wp-content/themes/x/framework/views/global/ to my child theme’s folder /framework/views/global/.

    But doesn’t seem to me that this has the search results layout. Am I wrong?

    thanks

    #617811

    Rue Nel
    Moderator

    Hi @mrk,

    Please notice the condition above the code. Instead of having this, elseif ( is_archive() ), you need to add the search condition as well. Perhaps the contents of your _index.php file should be this:

    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_INDEX.PHP
    // -----------------------------------------------------------------------------
    // Includes the index output.
    // =============================================================================
    
    $stack = x_get_stack();
    
    if ( is_home() ) :
      $style     = x_get_option( 'x_blog_style', 'standard' );
      $cols      = x_get_option( 'x_blog_masonry_columns', '2' );
      $condition = is_home() && $style == 'masonry';
    elseif ( is_archive() || is_search() ) :
      $style     = x_get_option( 'x_archive_style', 'standard' );
      $cols      = x_get_option( 'x_archive_masonry_columns', '2' );
      $condition = is_archive() && $style == 'masonry';
    else :
      $condition = false;
    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(); ?>

    As this is all custom development, regretfully we won’t be able to assist further. Custom development is outside the scope of our support. We’re happy to provide advice and get you started in the right direction, but you would still be responsible for the implementation.

    Thank you for your understanding.

    #617837

    MrK
    Participant

    Thanks guys so anyway this is the page I need to code into.

    Your code didn’t work but at least now I know where to code.

    As you said before you don’t do paid customisation right?

    thanks

    #617838

    MrK
    Participant

    Whatever I do on the _index.php page has impact just on the categories layout not on the search one.

    #617930

    Jack
    Keymaster

    Hi there MrK,

    Hope you’re well today, I’m afraid we don’t do paid customisations currently.

    The code should be working, though we can’t actually code it for you, could you share the code you’re currently using for the custom search, we can then take a look to see if there’s anything obvious to us as to why it won’t work. 🙂

    Thank you!