Change navigation menu item position

This topic contains 8 replies, has 3 voices, and was last updated by  Y A 9 years, 9 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #29628

    Y A
    Expired Member
    Post count: 156

    Hi,

    I would like to change the position of the items added by GDF.
    For example, “Listings”, “Add Listing”, and “Change location”.

    Where can I edit the position of these items?

    I understand that if I want to manually add an item at the end, I should set a very high position (https://wpgeodirectory.com/support/topic/add-menu-item-after-geodirectory-menu-items/).

    However, when another plugin (i.e. Buddypress) adds a menu item, it appears before the GDF menu items.

    I would like it to be in the following order:
    Listings – Add listing – Change Location – Buddypress item – Custom item

    Thanks,
    YA

    #29749

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi YA,

    You just have to play with the priority’s

    first remove the items from their current priorit then re-add them, for example if u wanted to reverse the order of the default GD links and the locatiosn switcher

    
    
    remove_filter('wp_nav_menu_items','geodir_menu_items', 100);
    add_filter('wp_nav_menu_items','geodir_menu_items', 50,2);
    
    remove_filter('wp_nav_menu_items','geodir_location_menu_items', 110);
    add_filter('wp_nav_menu_items','geodir_location_menu_items', 40, 2);

    Thanks,

    Stiofan

    #29766

    Paolo
    Site Admin
    Post count: 31206

    Hi,
    let us know if we can set this as resolved.
    Thanks

    #29774

    Y A
    Expired Member
    Post count: 156

    Hi,

    This indeed allows me to re-order GDF items (location_menu_items and menu_items).
    I have tried setting the position at 1 or 40, but it still appears AFTER my normal menu-items (contact page, buddypress items).

    #29781

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    ok to get both the GD items BEFORE the menu please remove the other bits of code and add this:

    
    
    remove_filter('wp_nav_menu_items','geodir_menu_items', 100);
    add_filter('wp_nav_menu_items','geodir_menu_items_mycustom', 50,2);
    
    remove_filter('wp_nav_menu_items','geodir_location_menu_items', 110);
    add_filter('wp_nav_menu_items','geodir_location_menu_items_mycustom', 60, 2);
    
    function geodir_menu_items_mycustom($items, $args){
    
    		$location = $args->theme_location;
    		
    		$geodir_theme_location = get_option('geodir_theme_location_nav');
    		
    		if ( has_nav_menu( $location )=='1' && is_array($geodir_theme_location) && in_array($location,$geodir_theme_location) ) {
    			
    			$items = geodir_add_nav_menu_items().$items;	
    			return $items;
    			
    		}
    		else
    		{
    			return $items;
    		}
    }
    
    function geodir_location_menu_items_mycustom($items, $args)
    {
    	
    	$location = $args->theme_location;
    	
    	$geodir_theme_location = get_option('geodir_theme_location_nav');
    	
    	if ( has_nav_menu( $location )=='1' && is_array($geodir_theme_location) && in_array($location,$geodir_theme_location) ) {
    		
    		$items = add_nav_location_menu_items().$items;
    		
    	}
    	
    	return $items;
    }

    Thanks,

    Stiofan

    #29784

    Y A
    Expired Member
    Post count: 156

    Thanks boss.
    That worked like a charm.

    Best,

    YA

    #29792

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Great! Feel free to leave us a review https://wordpress.org/support/view/plugin-reviews/geodirectory 🙂

    Thanks,

    Stiofan

    #29825

    Paolo
    Site Admin
    Post count: 31206

    FYI, given that you are using Buddyrpess:

    https://wpgeodirectory.com/support/topic/geodirectory-buddypress-integration-addon-beta-released/

    Hope you like it! 🙂

    #29843

    Y A
    Expired Member
    Post count: 156

    NICE. Thanks guys.
    Will certainly leave a review.

    – YA

Viewing 9 posts - 1 through 9 (of 9 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