Next and Previous buttons on Detail Page
This topic contains 10 replies, has 2 voices, and was last updated by Kiran 8 years ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
March 7, 2017 at 7:19 pm #366000
Hi,
I am using Starter Directory Theme and Supreme child theme.Selected “Enable location filter on related post” under ‘Geodirecory->Design->Detail’ tab on the ‘Related Post Settings’ section.
From this selection I see a “Next” and “Previous” button at the bottom of my detail page. I like that option, but when I click on next, it seems to ramdomly select any listing as the next listing.
I would like to stay on the same listing, for example if I am viewing a photography listing and I click on next I wan to see another photography listing, not some other category listing. Is there a way to do that?Under the “Related Post Settings” I have set “Relate to” to “Caterories”.
The “Sort by” option is set to “Latest”. I wish it has the option to sort by “Category” is there a way to do that?So, when I click on next at the bottom of the page I would like to go to the next listing but in the category, is there a way to do that?
Thank you.
March 7, 2017 at 11:04 pm #366034Hi I see I had some spelling errors in my previous post.
I meant to say that when I click on the next button at the bottom of the detail page I would like to display another listing of the same category, not just some random listing.Thanks,
March 8, 2017 at 7:48 am #366074Hi Rigots,
> Under the “Related Post Settings” I have set “Relate to” to “Categories”.
The “Sort by” option is set to “Latest”. I wish it has the option to sort by “Category” is there a way to do that?
< No, currently there is no such option to sort by categories for Related Listings.> So, when I click on next at the bottom of the page I would like to go to the next listing but in the category, is there a way to do that?
< Use following code snippet to show next/previous listing within current category only.function gd_previous_next_post_with_same_category( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) { global $wpdb, $plugin_prefix; if ( !empty($post->post_type) && !empty( $post->default_category ) && in_array( $post->post_type, geodir_get_posttypes() ) ) { $conditions = " AND default_category = %d"; $values = array( (int)$post->default_category ); $where .= $wpdb->prepare( $conditions, $values ); } return $where; } add_filter( 'get_previous_post_where', 'gd_previous_next_post_with_same_category', 11, 5 ); add_filter( 'get_next_post_where', 'gd_previous_next_post_with_same_category', 11, 5 );
Thanks,
KiranMarch 9, 2017 at 3:19 am #366269Hi Kiran,
Thank you for the info. This almost worked.Each time I search a category and then go into one of its listings then I only see a “Previous” button at the button of the details page. If I click on the previous button then it goes to previous listing in the same category and it gives me the option to go select only “Next” and I can go to the next listing too and then I only have the option to select previous as if I had only two listings to toggle in, but there are 4 or more listings on the categories I am using to test this.
Any idea what might be happening?
March 10, 2017 at 7:10 am #366514Hi,
Previous & Next listing also filters the current location.
For ex:
Suppose current listing has location “san-jose” & default category “catering” then it shows Previous & Next listings if listings has location “san-jose” & default category “catering”.If you reason except this then let me know steps with urls.
Thanks,
KiranMarch 14, 2017 at 6:59 pm #367303This reply has been marked as private.March 15, 2017 at 4:29 am #367384This reply has been marked as private.March 15, 2017 at 6:33 am #367399This reply has been marked as private.March 15, 2017 at 6:41 am #367400This reply has been marked as private.March 15, 2017 at 10:20 pm #367598Hi Kiran,
Do you have any sample custom code on how to use next/previous skipping the location filter?When I do a search and land on the search results and then I click on one listing details I would like the next and the previous listing to be in the order of the search results.
Is these doable?
March 16, 2017 at 8:07 am #367639Hi There,
You can use following code snippet to skip location filter from previous/next links.
function gd_plugins_loaded() { remove_filter( 'get_previous_post_where', 'geodir_previous_next_post_where', 10, 5 ); remove_filter( 'get_next_post_where', 'geodir_previous_next_post_where', 10, 5 ); } add_action( 'plugins_loaded', 'gd_plugins_loaded' );
To filter next/previous listing links with searched results, it required more code customization so you have to hire developer to do that.
Thanks,
Kiran -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket