AnonymousInactive
Thanks Trevor! I really appreciate your help here.
It looks like the original code in the results.php, “<?php the_date();?>”, was working inconsistently as it would only pull back dates for random posts. Possibly a bug with the plugin…
When I changed the code to “<?php echo get_the_date();?>”, all of the dates for published posts started displaying properly.
Cheers!
Matt
If it is in the results your are talking about, in each post, then that would need to be coded in to the PHP template being used for the results page. Which file that is depends on the Display Results Method you are using in the form. It could be a theme template (custom or standard coding), a plugin template, or a template based on our plugins default results.php file.
Whichever it is, would depend on ease, but I suspect that you would need a third party coder even for the easiest of these alternatives.
Yes, like this:
global $searchandfilter;
$sf_current_query = $searchandfilter->get(12204)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
echo '<div>Nothing to see here folks!</div>';
} else {
// your template archive code/loop OR results.php code here
}
AnonymousInactive
Hi Trevor, thanks for the prompt reply, however that’s not the issue. Please look at my stackexchange thread which explains what I am trying to achieve:
https://wordpress.stackexchange.com/questions/318675/template-loop-add-switch-case-php
Also another question, doesn’t your results.php need to have wp_reset_postdata(); for best practices?
AnonymousInactive
Hi,
I am trying to modify the results.php template so that I can display a different loop for my different custom post types. I was trying something along the lines but it doesn’t work. I think my syntax is wrong in the first place. If you have any pointers on the best way to achieve this please let me know.
<?php $curtype = get_post_type( $post->ID ); switch($curtype){
case “events”: return ‘events code’;
break;
case “venues”: return ‘venues code’;
break;
}
?>
many thanks,
Andrew
AnonymousInactive
I use results.php, this is my problem?
When you originally made your results.php file, did you use the contents of the exemplar results.php file or the contents of the exemplar results-infinite-scroll.php scroll?
The structure of the two exemplar files is different.
AnonymousInactive
HI,
We have a custom post type called FAQ. That post type has a taxonomy called Faq Categories.
At the moment we have a standard WordPress page set up with the shortcode & results shortcode from our form using ajax. This is working fine. We have styled our results.php file how we want.
However, we also want to display the same form and results style on our custom taxonomy template but obviously only show results for the current tern. eg.
faq_category/financial shows only the financial results with the a, using ajax, and our results.php styling / layout.
Is it possible to have the form limit the results to just the current term and use Ajax?
Thanks
Adam
AnonymousInactive
Hi,
So I’ve copied the results.php file to mytheme/search-filter/results.php and changed both instances of ‘Older Posts’ but it hasn’t changed. ie:
<div class=”nav-previous”><?php next_posts_link( ‘More posts’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Previous posts’ ); ?></div>
What else can I check?
Thanks
Ah, I can see what you have done now. It would need for part of the blog page template to be placed in the results.php file and for the blog template instead of calling the results shortcode, to call the content.
I can write this for you if you want:
In blog-page.php change lines 24-29:
<div class="page-blog page-blog-title">Recent posts</div>
<div class="blog-posts">
<?php echo do_shortcode('[searchandfilter id="463" show="results"]');?>
</div>
</div>
with:
<?php the_content(); ?>
Next, in the results.php file, find lines 68 and 69:
</a></a>
</div>
I believe these have errors and should be just:
</a>
At the very end of the file is a blank line, after this:
else ?>
<?php {
}
?>
Here add two closing tags:
</div>
</div>
Now find lines 25 and 26 (which are blank) and paste these lines:
<?php global $searchandfilter;
$sf_current_query = $searchandfilter->get(463)->current_query();
if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
$page_title = "Recent Posts";
} else {
$page_title = "Search results for: " . $sf_current_query->get_search_term();
}?>
<div class="page-blog page-blog-title">Recent posts</div>
<div class="blog-posts">
I think that will do as you want. The title must be inside the results.php for it to be affected by if there are results.