I’m sure what you’re asking can be done, but there’s a far simpler, significantly easier solution, just register each menu multiple times for each language, and show different menus for different languages.
This way you don’t need to figure out how to filter out menu items depending on GET variables, and your pages become more cacheable ( you could modify rewrite rules so that your URLs are pretty and take the form example.com/es/hello-world rather than example.com/hello-world?lang=es )
The benefit of this is that your language menus can be completely different, and they’ll work everywhere on your site, not just on posts and pages
Related Posts:
- Automatically add images to a menu
- Disable Attachment Pages Completely
- Print number of post (in reverse)
- Best practice for migration friendly images in posts/pages?
- get_the_title() gets printed out twice
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Show About and Contact Us page when they’re clicked in the top menu.
- WordPress Search
- Edit and delete permissions pages and posts
- My worpress search page is showing no results
- How can I check if a post with a particular slug or title exists?
- Split post or page content in two or more columns
- Getting page / post URL on publish and / or update
- Get current_post in reverse order with pagination
- List of child pages fetch next results at link click
- Sending the reset password link programatically
- start_lvl Ignored in Custom walker_nav_menu
- Any guides on creating custom admin pages?
- wp_delete_auto_drafts() deletes links in menus
- Check if a menu is empty?
- Walker class: Problems with understanding how walk() method can be called without error
- How to Use the Function is_user_logged_in To Display Different Menus?
- How can I access the “description” of a menu item?
- Insert code when users come from an specific referer
- How to display related posts from parent category
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- items_wrap not working
- Have CSS Class Added with `is_page()` WP function
- Run a filter when a walker runs
- How can I use wp_query to show all product data using just the products ID?
- Trying to add attribute to my posts’ featured image
- Input type search in Menu
- WP Walker using custom css classes
- Loop through categories and display posts title under each dropdown
- How to store post ID’s in cookie or session to display the same posts later
- Create Page To Count Comments For Each Post In WordPress Site
- How to change menu order item
- Using wp_list_pages() after calling query_posts()
- Two menus show up
- Display related posts without a plugin
- $wpdb returns duplicate posts
- How to show an entire post content and not also the excerpt?
- Increment paged on WP_Query
- How to display different submenus?
- Modify main query before it run without pre_get_post
- Get the name of menu item with wp_nav_menu
- .html end of URl affected to SEO?
- Get parents child pages
- Update if post with specific title exists
- Removing custom sort order from admin page listing
- PHP Output also in Child theme, but different
- $wpdb->get_results breaking page?
- Why can’t I add a custom image in my navigation?
- Remove the Tag from wp_nav_menu
- How do I add my PHP app to a WordPress page whilst keeping semantic URLs?
- Cascading dropdown select search based on Parent Page & Child Page
- Advanced Query posts
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- My Custom Post Type AJAX Query is Returning no posts – why?
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- Don’t update modified post date when user add a product review or comment?
- Limit the number of characters/words in an excerpt for a related posts section
- How to put 2 php codes in functions.php without site crashing
- wp_get_nav_menu_items() with ACF
- How to switch between two primary menus (programatically0
- Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]
- Closing Comments conditionally in comments.php
- How to center all text body in single.php at once?
- Failed to load resource: the server responded with a status of 500 () post.php
- How to give custom roles the capability to edit one Menu instead of every Menu
- Primary navigation menu with timed items from custom post type
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- How do if all posts has this category ID then do this
- loading a php file to a specific page id
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Getting error in sql query
- How limit the width of a fixed menu-bar on scroll?
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- Two theme locations for two menus, but only one is showing up
- insert thumbnail image from php script
- Contact form field in wordpress menu
- How to call a certain object/menubar in a PHP file
- Add custom class to existing menu items from custom meta
- Remove all nav menu classes except those which begin with certain letters
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Trying to see if page is category or single and displaying title with appropriate heading tag
- How to change the menu color
- Nav Menu Display
- Adding a unique class to wp_nav_menu
- I want Page titles and excerpts to show up on home.php in certain order
- ACF: Echo page title when checkbox is checked
- foreach all the post
- Blog Posts not sorted and pagination not adjusted after filtering some category
- Add multiple HTML attributes to an Elementor button
- Custom nav with bootstrap dropdown
- Bulk data save in custom table