Forums › Forums › Search & Filter Pro › integration with custom template
Tagged: get_search_query custom theme
- This topic has 9 replies, 2 voices, and was last updated 4 years, 11 months ago by
Trevor.
-
Anonymous(Private) May 31, 2020 at 1:07 am #246672
Hi,
I am trying to make your plugin works with my custom theme/template. Could you please give me detailed instructions including settings and where I should paste your code suggestions because I read other suggestions and I could not apply what is suggested in them.
I am using EDD plugin but with a custom theme/search.
The search in the theme I am using is working as follows:
There is a template for homepage where the search bar appears and the code inside it is below “code 1”>
When I hit the search button, the browser is directed to the following link:
https://home_url/?s=searchTerm&post_type=downloadThen I believe search.php is called. The code inside search.php is below as “code 2”.
Thanks,
AhmedCode 1 in template home page
<div class="search_EDD"> <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> <?php $searchresults = get_search_query(); ?> <?php if ($searchresults != ('')){ ?> <input type="text" placeholder="<?php _e( 'Search here...', 'searchTerm' ); ?>" value="<?php echo $searchresults; ?>" name="s" id="s" /> <?php } else { ?> <input type="text" value="" name="s" id="s" placeholder="<?php _e( 'Search codes ahmed2...', 'searchTerm' ); ?>" /> <?php } ?> <input type="hidden" name="post_type" value="download" /> <input type="submit" id="searchsubmit" value="<?php _e( 'Search', 'searchTerm' ); ?>" /> </form> <div class="clear"></div> </div>
code 2 in search.php
<h1 class="title"><?php _e( 'Results For ', 'squarecode' ); ?>"<?php echo get_search_query(); ?>"</h1> <?php if(have_posts()) : while(have_posts()) : the_post(); ?> <?php if ( get_post_type() == 'page' ) { ?> .... <?php } elseif ( get_post_type() == 'download' ) { ?> // code that show the results in the way I want to see
Anonymous(Private) June 1, 2020 at 2:05 am #246687Some clarification of what I would like to achieve:
I would like to keep using the same search bar I am using in the homepage from the theme and when I hit the search button the results are shown as before using the theme template but adding to it your very nice filters.I managed to implement the first part of the task, which is using the theme search bar in the homepage to call “search & filter” form. I manage doing this by changing “code 1” shown above to code 1 modified below where “page_id = 17690” is the page that includes the short codes of the “search & filter” form and I choose “Using a short code” in the Display Results setting.
But now I need to implement the second part which is showing the results as the theme was showing before and keep showing the filters I added in the “search & filter” form. Could you help me in this.
Thanks,
AhmedCode 1 modified in template homepage
<div class="search_EDD"> <form role="search" method="get" id="search_AH" action="<?php echo home_url( '/' ); ?>"> <input type="hidden" name="page_id" value="17690" /> <input type="text" name="_sf_s" id="_sf_s" /> <input type="submit" id="searchsubmit" value="Search" /> </form> <div class="clear"></div> </div>
Trevor(Private) June 4, 2020 at 4:27 pm #247461Is the actual content (the words) correct? I can see that the original shows only the year, but that can be fixed to make our template show just the year as well. Both have Title, Excerpt and Date (year).
If so, very little change is needed to our template.
The guide to customising is here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
In the main, it may be a case of simply adding the classes and HTML containers used by the original.
-
AuthorPosts