Custom URL Storage WordPress
February 11, 2025 ยท AI Conversations
### **Where Custom URLs Are Stored**
1. **`wp_posts` Table:**
– Each menu item is stored as a post with `post_type = "nav_menu_item"`.
– The `post_title` column is used for the menu label (the visible name).
– The `guid` column might store the URL temporarily when added.
2. **`wp_postmeta` Table:**
– The actual custom URL is stored in the `wp_postmeta` table as a meta value with `meta_key = "_menu_item_url"`.
### **Example Query to Find Custom URLs in Menus**
SELECT wp_posts.ID, wp_posts.post_title, wp_postmeta.meta_value AS custom_url
FROM wp_posts
JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE wp_posts.post_type = 'nav_menu_item'
AND wp_postmeta.meta_key = '_menu_item_url';
This will return all custom URLs assigned to menu items.
Let me know if you need help modifying or exporting these URLs! ๐
### **Update Custom URL in WordPress Menu**
UPDATE wp_postmeta
SET meta_value = 'https://new-url.com'
WHERE meta_key = '_menu_item_url'
AND post_id = (SELECT ID FROM wp_posts WHERE post_title = 'Menu Item Name' AND post_type = 'nav_menu_item');
### **Explanation:**
– Replace `'https://new-url.com'` with the new URL.
– Replace `'Menu Item Name'` with the
### **SQL Query to Replace Part of the URL in Menu Items**
UPDATE wp_postmeta
SET meta_value = REPLACE(meta_value, 'old-url.com', 'new-url.com')
WHERE meta_key = '_menu_item_url';
### **Explanation:**
– This will replace `'old-url.com'` with `'new-url.com'` in all custom menu URLs.
– Only affects menu items because of `WHERE meta_key = '_menu_item_url'`.
#### **Example Use Case:**
– Changing all URLs from `http://example.com/` to `https://newexample.com/`.
Let me know if you need a more specific query! ๐