Custom URL Storage WordPress

User
where custom url store in wordress for apperance menu
Assistant
In WordPress, custom URLs added to the **Appearance โ†’ Menus** section are stored in the database in the `wp_posts` and `wp_postmeta` tables.

### **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! ๐Ÿš€

User
sql query update
Assistant
If you need to update a custom URL in the WordPress menu, you can use the following SQL query:

### **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

User
replace sql query
Assistant
If you want to **replace** a part of the URL in all WordPress menu items, you can use the `REPLACE()` function in SQL.

### **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! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *