AnonymousInactive
Ok one more thing i found out. It just happens when i create a search-filter folder in my theme directory where i put the results.php in ….
Hey Travis are you using the shortcode method to display results? (hence using the results.php)? Then in this case, you will notice that they actually pass the custom query to the pagination function(s).
Therefor you need to use the pagination variable too:
So
'current' => max(1, get_query_var('paged')),
Should become something like:
'current' => max( 1, $query->query['paged'] ),
So the paged var inside the custom query (the shortcode method) is used rather than the global var.
Thanks
AnonymousInactive
Hello,
I’m running into an issue with pagination on the results page. The “next_posts_link()” and “previous_posts_link()” pagination that comes with the default results.php file works, but it doesn’t seem to work when I try to use the paginate_links() function. When the page is initially loaded, the pagination links work. For example, the links’ href are “?sf_paged=2” and so on. But, when I click on a page link in the pagination and the new page loads, the pagination links no longer work. they now all have hrefs as “?sf_action=get_results” and don’t link anywhere. Pagination links also won’t work when a filter is chosen. all the pagination links become “?sf_action=get_results&_sft_classification=oversight-and-development” or whatever the chosen filter is.
For reference, here is the pagination code I’m using:
<?php
global $wp_query;
$big = 999999999;
if ($query->max_num_pages > 1) {
echo '<div class="pagination">';
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $query->max_num_pages,
'prev_text' => __('< PREV'),
'next_text' => __('NEXT >'),
));
echo '</div>';
}
Thank you for your help.
Travis
AnonymousInactive
You can set this to resolved – I just recreated my results.php in my theme and it’s now working again.
AnonymousInactive
Hey Ross,
Hope you’re well.
Any chance you can tell me when’s the next plugin release? And if you’re planning to let “us” define the results.php file path?
Cheers,
V.
Create a new template, call it something like search-filter-results.php
and use this in your settings.
Then use the following code for search-filter-results.php
:
https://gist.github.com/rmorse/f4c824817ef7d0de4f98
Thanks
AnonymousInactive
Nope 🙂 Just need the ability to modify results.php without touching the WP theme’s files. So I figured the only way to do this would be trough the custom plugin.. but no 🙂
Yeah, just give us a filter or something, so we can change the path to the results.php file without changing WP theme’s structure.
Cheers
AnonymousInactive
Hi Ross,
Thanks for the quick reply. Unfortunately, it didn’t resolved my issue here.
Example: I am not allowed to touch, nor access WP theme’s folders or files. I need to be able to load results.php file from within plugin.
Is there a way to define new results.php file path (/path/to/my/plugin/myresultstemplate.php)?
Many thanks,
V.
Hi there
I guess the best way to do this would be to use the standard way of customising the results template via the theme..
However, you wouldn’t use all the standard loop code etc, you would just empty the results.php file in your theme, and load the file that you desire using PHP, something like:
results.php:
<?php
include '/path/to/my/plugin/myresultstemplate.php';
?>
Thanks
AnonymousInactive
Hi Ross,
Love the plugin. Thanks for this.
I need to customise results.php, but I need to be able to do that from a plugin, NOT from the theme. Right now, the only way to do so, according to the docs, we can copy paste search-filter/results.php in our theme’s dir.
Can you please advise on how to maybe overwrite/extend Search_Filter_Query Class (the_results function), from a custom plugin, and define new location for search-filter/results.php?
Any help is much appreciated.
Thank you,
V.