Forums › Forums › Search & Filter Pro › Multiple forms with shortcodes and different templates
- This topic has 5 replies, 3 voices, and was last updated 8 years, 3 months ago by Anonymous.
-
Anonymous(Private) September 29, 2015 at 12:29 pm #26155
Hi,
You suggest this:
Multiple Search Forms, – I don’t want all my results looking the same!?
For example, if a Search Form had an ID of 14, then I would create a template in this folder called
14.php
– that only this Search Form could use for displaying its results – the file would then be located: wp-content\themes\your-theme-name\search-filter\14.php
The problem is that not always the ID is known. For example I work in local server, the when I upload the page to production the ID’s is different.My first attemp was:
result.php
<?php while ($query->have_posts()) { $query->the_post(); ?> <?php if (is_page_template("custom-mycpt.php")) get_template_part ('templates/item','mycpt'); else get_template_part ('templates/item','posts'); ?> <?php } ?>
The problem is using Ajax when refresh ‘is_page_template’ don’t works correctly.
My second attemp is:
if ($query->query['post_type'][0] == 'mycpt') get_template_part ('templates/item','mycpt'); else get_template_part ('templates/item','posts');
This works fine but I don’t know is a good solution.
Thanks.
Ross Moderator(Private) September 30, 2015 at 11:44 am #26212Hey Jose
Yeah unfortunately you will have to rename the php files to match the IDs of your search form in your environment.
What I’m planning to do is an option so you can give a “name” to search form – so that it has its own slug based on name, and not ID. This way, even if the search form IDs don’t match you won’t have any problems.
Sticking this on my to do list now.
Thanks
-
AuthorPosts