Conditional Tabs
This topic contains 9 replies, has 3 voices, and was last updated by Stiofan O’Connor 8 years, 9 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
January 21, 2016 at 9:50 am #69692
Hello! For the listings detail page is there a way to hide the “Related Listings” tabs for certain listings? I would like to be able to remove the review based on certain tags being present. For example, if I tag the listing as a HIKE I don’t want the related listings tab to appear, but if that tag is not present – then it should appear.
Thank you.
January 21, 2016 at 6:48 pm #69795Hi,
please see: https://wpgeodirectory.com/re-order-tabs-in-a-listing-detail-page/
at the bottom you’ll find a part: https://wpgeodirectory.com/re-order-tabs-in-a-listing-detail-page/
Thanks
January 21, 2016 at 8:04 pm #69823Thank you @paolo, but I only see that this tutorial tells you how to rearrange the tab orders. I would like to hide a tab order for certain listings.
January 21, 2016 at 8:34 pm #69830Yes you can re-order by moving around or remove them by removing the specific call for a given tab from the array.
Hope it’s clear.
let us know,
January 21, 2016 at 9:36 pm #69838Okay I figured out to only affect the listings I want to change. But removing the snippet doesn’t seem to have any effect, the related listing tab is still showing up. I’ve removed the “Related Listings” array entirely. Please see code:
// This is the add filter action which will use the function below to re-order tabs. add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ; //This is the actual function to re-order tabs function geodir_detail_page_tab_list_extend($tab_array) { // before creating the new array which will re-order the tabs, we check if the custom post type is "Places" if ( has_term ( 'hikes', 'gd_placecategory' ) ) { // here you can modify the array and re-arrange tabs as you wish, you can create a completely new array too. // this is the review tab, by default is the 7th, but here we moved it to position 1. if(isset($tab_array['reviews'])){ $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array // IMPORTANT the following code tells GeoDirectory that this is the new default active tab $new_tab_array['reviews']['is_active_tab']='1'; unset($tab_array['reviews']);//unset in old one } // this is the post profile tab, by default is the 1st if(isset($tab_array['post_profile'])){ $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array // IMPORTANT the following code tells GeoDirectory that this is no longer the default active tab $new_tab_array['post_profile']['is_active_tab']=''; unset($tab_array['post_profile']);//unset in old one } // this is the post info tab (optional for custom fields), by default, if available, is the 2nd. if(isset($tab_array['post_info'])){ $new_tab_array['post_info'] = $tab_array['post_info'];// set in new array unset($tab_array['post_info']);//unset in old one } // this is the images tab, by default is the 3rd if(isset($tab_array['post_images'])){ $new_tab_array['post_images'] = $tab_array['post_images'];// set in new array unset($tab_array['post_images']);//unset in old one } // this is the video tab, appears only if there are videos and by default is the 4th if(isset($tab_array['post_video'])){ $new_tab_array['post_video'] = $tab_array['post_video'];// set in new array unset($tab_array['post_video']);//unset in old one } // this is the speacial offer tab, appears only if there are special offers and by default is the 5th if(isset($tab_array['special_offers'])){ $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array unset($tab_array['special_offers']);//unset in old one } // this is the map tab, by default is the 6th if(isset($tab_array['post_map'])){ $new_tab_array['post_map'] = $tab_array['post_map'];// set in new array unset($tab_array['post_map']);//unset in old one } // now we set any remaining tabs that have not been assigned an order foreach($tab_array as $key=>$tab){ $new_tab_array[$key]=$tab; } return $new_tab_array ; } // If Check for Places ends here // Here we tell GeoDirectory to use the regular array for all other custom post types. else { return $tab_array ; } }
Thank you.
January 21, 2016 at 11:36 pm #69857is hikes a tag or a category?
Your condition is looking for a category hikes.
If that’s a tab you should use:
If ( has_term ( ‘hikes’, ‘gd_place_tags’ ) ) {//rest of the function}
I think you are also making confusion with the active tab code.
Let us know,
January 21, 2016 at 11:42 pm #69860Hikes is a category. The code for that is working just fine. When this function is enabled I can see it taking effect because the order of my tabs are rearranged. However, I am trying to remove the “Related Listings” tab and I don’t know how to to that. From the tutorial you forwarded me to, I completely took out the following code
// this is the related listing tab, it is optional and by default is the 8th if(isset($tab_array['related_listing'])){ $new_tab_array['related_listing'] = $tab_array['related_listing'];// set in new array unset($tab_array['related_listing']);//unset in old one }
However the “Related Listings” tab is still appearing. Thank you.
January 22, 2016 at 12:50 pm #69967Hi Joy,
Hopefully this example sheds light on it for you, if you need further help, please just ask.
Thanks,
Stiofan
January 22, 2016 at 7:45 pm #70104Got it! Thank you so much.
January 22, 2016 at 8:06 pm #70107Great! 🙂
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket