re-order tabs

This topic contains 5 replies, has 3 voices, and was last updated by  Paolo 7 years, 11 months ago.

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

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #208881

    sumi
    Expired Member
    Post count: 97

    Hi all,

    wonder if anyone can help…
    What am I doing wrong?!

    Set up custom tab, want it to appear after images, but won’t!
    Any advice appreciated. Thank you.

    
    
    
    // this is the snippet that adds the filter, calling the function below. 
    add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend') ;
     
    // this is the function that does the re-ordering that we call with the add filter snippet above.
    function geodir_detail_page_tab_list_extend($tab_array)
    {
     
     // here you can modify the array and re-arrange tabs as you wish, you can create a completely new array too.
     
    
        // this is the images tab
        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_special_offers2'])){
             $new_tab_array['post_special_offers2'] = $tab_array['post_special_offers2'];// set in new array
             $new_tab_array['post_special_offers2']['is_active_tab']='1';
             unset($tab_array['post_special_offers2']);//unset in old one
         }
    
        // this is the special offer tab
        if(isset($tab_array['special_offers'])){
             $new_tab_array['special_offers'] = $tab_array['special_offers'];// set in new array
             $new_tab_array['special_offers']['is_active_tab']='5';
             unset($tab_array['special_offers2']);//unset in old one
         }
    
        // this is the post info tab (optional for custom fields)
        if(isset($tab_array['post_info'])){
             $new_tab_array['post_info'] = $tab_array['post_info'];// set in new array
             $new_tab_array['post_info']['is_active_tab']='4';
             unset($tab_array['post_info']);//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 ;
    }
    
        // this is the post profile tab
        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']='98';
             unset($tab_array['post_profile']);//unset in old one
         }
     
    
        // this is the map tab
        if(isset($tab_array['post_map'])){
             $new_tab_array['post_map'] = $tab_array['post_map'];// set in new array
             $new_tab_array['post_map']['is_active_tab']='99';
             unset($tab_array['post_map']);//unset in old one
         }
     
        // this is the related listing tab
        if(isset($tab_array['related_listing'])){
            $new_tab_array['related_listing'] = $tab_array['related_listing'];// set in new array
             $new_tab_array['related_listing']['is_active_tab']='100';
            unset($tab_array['related_listing']);//unset in old one
        }
    #208986

    Kor
    Moderator
    Post count: 16516

    Hi Sumi,

    I’ve just checked the code and it seems incorrect. Could you tell us how do you want to arrange your tabs? Just list it down here and we’ll supply you the correct code. Also, do you think you can share temp admin access to your site so we can take a better look? You can post the details here using the private reply option below.

    Here’s a reference that might help achieve what you needed there. https://wpgeodirectory.com/re-order-tabs-in-a-listing-detail-page/

    Thanks!

    #209013

    Paolo
    Site Admin
    Post count: 31206

    Probably you are also using the wrong tab index name for your custom tab, where did you get that from?

    In the article linked by Kor, please review this part:

    If you paste the follwing code snippet in your active theme’s functions.php file instead of the previous function, tabs will disappear from the listing details page and instead you will see the array with all its info, including all tab indexes.

    
    
    add_filter('geodir_detail_page_tab_list_extend', 'geodir_detail_page_tab_list_extend_profile') ;
    function geodir_detail_page_tab_list_extend_profile($tab_array)
    {
    print_r($tab_array);
    }
    

    By doing so you can find the tab index for your custom tab made with fieldset. At this point remove the above code snippet and use the correct tab index for your function to re-order tabs.

    Let us know if that helped.

    Thanks

    #209033

    sumi
    Expired Member
    Post count: 97

    Hi

    tried print_r, but didnt realise at wrong tab index name until you said, lol.

    played around – working, now.

    Sorted.
    Thanks guys.

    #209034

    sumi
    Expired Member
    Post count: 97
    This reply has been marked as private.
    #209040

    Paolo
    Site Admin
    Post count: 31206

    Good job! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

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

Open Support Ticket