How to change default tab (from profile to review)?
This topic contains 21 replies, has 5 voices, and was last updated by Paolo 9 years, 5 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: tab
-
AuthorPosts
-
November 17, 2014 at 7:59 am #21693
Hi,
I’m using GDF modern, and I’d like to set up as default tab not the profile of the listing but the review section. How to do? Is there an option or need to change a php file? (or better add an istruction into functions.php of the theme)Thanks!
November 17, 2014 at 8:05 am #21694A search came up with this: https://wpgeodirectory.com/support/topic/exclude-selected-tabs-from-detail-page-if-empty/#post-7305
November 24, 2014 at 1:47 pm #22451Thanks. I followed instructions, and inserted the code mentionned by adding at first place the review tab instead the profile tab. But opening a detail page is still show the Profile as default (even in 2nd tabs instead of 1st). My question is how can I force open the review tab instead the profile tab. Maybe through CSS? Thanks again
// begin change order tabs // add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ; function geodir_detail_page_tab_list_extend($tab_array) { // here u can modify this array, u can create a completely new one too. if(isset($tab_array['reviews'])){ $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array unset($tab_array['reviews']);//unset in old one } if(isset($tab_array['post_profile'])){ $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array unset($tab_array['post_profile']);//unset in old one } 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 } 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 } 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 } 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 } 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 } 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 } // 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 ; } // end change order tabs //
November 28, 2014 at 2:36 pm #22937Up.
Need to change some css?
Thanks!November 28, 2014 at 2:41 pm #22939Might be simpler to append #reviews to each url going to a detail page.
Not sure whether that is possible, but Paolo should be able to tell you.December 9, 2014 at 7:26 pm #23956Thanks for tip. I’d prefer that the default url shows the reviews without append the #reviews.
I see that in css is:
<dd > <a data-tab="#reviews" data-status="enable">Reviews</a> </dd> <dd class="geodir-tab-active" > <a data-tab="#post_profile" data-status="enable">Profile</a> </dd>
So to move
class="geodir-tab-active"
I have to modify a php file? Or need to add a php line into theme functions.php?
Thanks
December 10, 2014 at 4:44 pm #24021OK this is easier than you think…
if(isset($tab_array['reviews'])){ $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array $new_tab_array['reviews']['is_active_tab']='1'; unset($tab_array['reviews']);//unset in old one } if(isset($tab_array['post_profile'])){ $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array $new_tab_array['post_profile']['is_active_tab']=''; unset($tab_array['post_profile']);//unset in old one }
the
...['is_active_tab']='1';
sets any tab to be the default but you can have only one so u must remove the profile tab with the same code
...['is_active_tab']='';
Thanks,
Stiofan
February 23, 2015 at 12:54 pm #31755Hi, I’m still having some issues on this little hack: the order of the tabs has changed, but it still shows the description as active tab instead of reviews tab. I used the code following above tips, where I’m wrong? Thanks!
I put it on gdf child theme / functions.php , before the final ?>
// begin change order tabs // /** https://wpgeodirectory.com/support/topic/how-to-change-default-tab-from-profile-to-review/#post-24021 **/ add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ; function geodir_detail_page_tab_list_extend($tab_array) { // here u can modify this array, u can create a completely new one too. if(isset($tab_array['reviews'])){ $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array $new_tab_array['reviews']['is_active_tab']='1'; unset($tab_array['reviews']);//unset in old one } if(isset($tab_array['post_profile'])){ $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array unset($tab_array['post_profile']);//unset in old one } 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 } 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 } 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 } 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 } 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 } 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 } // 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 ; } // end change order tabs //
February 23, 2015 at 9:52 pm #31820Hi,
as Stiofan suggested, please try:
// begin change order tabs // /** https://wpgeodirectory.com/support/topic/how-to-change-default-tab-from-profile-to-review/#post-24021 **/ add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ; function geodir_detail_page_tab_list_extend($tab_array) { // here u can modify this array, u can create a completely new one too. if(isset($tab_array['reviews'])){ $new_tab_array['reviews'] = $tab_array['reviews'];// set in new array $new_tab_array['reviews']['is_active_tab']='1'; unset($tab_array['reviews']);//unset in old one } if(isset($tab_array['post_profile'])){ $new_tab_array['post_profile'] = $tab_array['post_profile']; // set in new array $new_tab_array['post_profile']['is_active_tab']=''; unset($tab_array['post_profile']);//unset in old one } 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 } 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 } 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 } 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 } 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 } 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 } // 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 ; } // end change order tabs //
You were missing the
$new_tab_array['post_profile']['is_active_tab']='';
in post profile to make the tab inactive.
Let us know,
Thx
February 27, 2015 at 9:45 am #32235Works fine now, thank you
March 30, 2015 at 7:13 pm #35601I noticed that it modifies both listing reviews and events. Is there a way to make it different? I mean, let this hack work only for listing reviews, not for events?
ThanksMarch 30, 2015 at 8:06 pm #35612Yes, wrap the function in a conditional statement to determine on which CPT to excecute it.
example :
if ( 'gd_place' == get_post_type() { // function here }
Change CPT accordingly.
Thanks
March 31, 2015 at 6:01 am #35671Thanks but maybe I didn’t put in right mode:
Parse error: syntax error, unexpected '{' in /home/../public_html/wp-content/themes/geodir_gdf-modern/functions.php on line 68
I added it before the add_filter
// begin change order tabs //
/** https://wpgeodirectory.com/support/topic/how-to-change-default-tab-from-profile-to-review/#post-24021 **/add_filter(‘geodir_detail_page_tab_list_extend’, ‘geodir_detail_page_tab_list_extend’) ;
if ( ‘gd_place’ == get_post_type() {
function geodir_detail_page_tab_list_extend($tab_array)
{
// here u can modify this array, u can create a completely new one too.
if(isset($tab_array[‘reviews’])){
$new_tab_array[‘reviews’] = $tab_array[‘reviews’];// set in new array
$new_tab_array[‘reviews’][‘is_active_tab’]=’1′;
unset($tab_array[‘reviews’]);//unset in old one
}
if(isset($tab_array[‘post_profile’])){
$new_tab_array[‘post_profile’] = $tab_array[‘post_profile’]; // set in new array
$new_tab_array[‘post_profile’][‘is_active_tab’]=”;
unset($tab_array[‘post_profile’]);//unset in old one
}// 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 ////
// } ////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
}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
}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
}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
}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
}// 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 ;
}}
// end change order tabs //March 31, 2015 at 3:07 pm #35707My bad, it should be
if ( 'gd_place' == get_post_type() ) { // function here }
Please see the missing ) after get_post_trype().
That should fix it.
Let us know,
July 25, 2015 at 8:10 pm #46979Hi, used if ( ‘gd_place’ == get_post_type() ) { // function here }
The details box stopped loading totally. Any fix. Thanks -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket