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, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #21693

    magnaromagna
    Expired Member
    Post count: 227

    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!

    #21694

    Guust
    Moderator
    Post count: 29970
    #22451

    magnaromagna
    Expired Member
    Post count: 227

    Thanks. 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 //
    
    #22937

    magnaromagna
    Expired Member
    Post count: 227

    Up.
    Need to change some css?
    Thanks!

    #22939

    Guust
    Moderator
    Post count: 29970

    Might 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.

    #23956

    magnaromagna
    Expired Member
    Post count: 227

    Thanks 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

    #24021

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    OK 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

    #31755

    magnaromagna
    Expired Member
    Post count: 227

    Hi, 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 //
    #31820

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    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

    #32235

    magnaromagna
    Expired Member
    Post count: 227

    Works fine now, thank you

    #35601

    magnaromagna
    Expired Member
    Post count: 227

    I 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?
    Thanks

    #35612

    Paolo
    Site Admin
    Post count: 31206

    Yes, 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

    #35671

    magnaromagna
    Expired Member
    Post count: 227

    Thanks 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 //

    #35707

    Paolo
    Site Admin
    Post count: 31206

    My 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,

    #46979

    hezekiah
    Buyer
    Post count: 115

    Hi, used if ( ‘gd_place’ == get_post_type() ) { // function here }
    The details box stopped loading totally. Any fix. Thanks

Viewing 15 posts - 1 through 15 (of 22 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount