-
AuthorPosts
-
October 7, 2015 at 2:57 am #614506
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 tosearch-filter.php
.2) In S&F, under “display results” you will need to tick
use custom template
and then set the filename tosearch-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 ofWP_Query
,get_posts
orquery_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
October 7, 2015 at 4:00 am #614578Hi 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!
October 7, 2015 at 4:07 am #614588Yes 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
October 7, 2015 at 5:26 am #614645Hi 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!
October 7, 2015 at 5:27 am #614646thanks guys
October 7, 2015 at 6:15 am #614708You’re welcome! 🙂
October 7, 2015 at 6:35 am #614728Sorry forgot: can you point me to the results php page to edit in order to have masonry?
October 7, 2015 at 6:53 am #614759Hi 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!
October 7, 2015 at 7:08 am #614788thanks guys so why when I get to search result I see an url like: mydomain.com/?sfid=1807
October 7, 2015 at 7:40 am #614836Hi,
That is a default behaviour of your third party plugin.
Please refer to the link below
Thanks
October 9, 2015 at 3:43 am #617788Hi 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
October 9, 2015 at 4:07 am #617811Hi @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.
October 9, 2015 at 4:35 am #617837Thanks 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
October 9, 2015 at 4:36 am #617838Whatever I do on the _index.php page has impact just on the categories layout not on the search one.
October 9, 2015 at 5:48 am #617930Hi 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!
-
AuthorPosts