Wordpress Custom Menues

I am currently working on a wordpress multisite project. I have set up a working environment in localhost. In the main menu there is a links to home, so is in subdirectory sites.

Now my problem is everything works find in testing server environments as the main site URL is myhost/xx/wordpress_site and sub directory sites are like myhost/xx/wordpress_site/sub_dir. In wordpress Appearance->menu you can only give a static url in the link URL field.

What I am looking for is to give a method like site_url().”/sub_dir” in that field so I don’t have to manually alter all the site home URLs when I upload the site to it’s destination domain. Which can be any form? Any simple solution regarding this problem its greatly appreciated. Thanks a lot.


I would not recommend to change anything on wordpress code or site url configuration. because when you will go to production you will have to change it back again. It will be the best if you will setup the same site configuration on your localhost, you can use the following configuration for your apache server and host file so you will be able to access your local site by your actual domain. This way your settings will remain the same and all site links will be the same. (rename mysite to your site url)

how to change host file: http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

how to add virtual host apache: http://httpd.apache.org/docs/current/vhosts/examples.html

Apache configuration:

<VirtualHost mysite.com:80>
        ServerName mysite.com
        DocumentRoot /var/www/mysite
        <Directory /var/www/mysite>
                Options FollowSymLinks
                AllowOverride All

host file configuration: mysite.com

restart apache and you will be able to work on localhost like it is the productin server. * Remove the following when you want to access the real server.

Similar questions

WordPress WP_Query: Display custom post type based on custom meta value, and also order on another custom meta value
I am using the WordPress plug-ins Advanced Custom Fields, and Custom Post Type UI. I have built a WP_Query to display a particular post type, filtered by a particular custom field value. I now want to sort the resulting posts by another custom field, date_of_publication rather than use WordPress's menu_order or date. The ACF documentation says to s...
Wordpress Custom Fields. Display custom fields from user profile on a custom page
On my wordpress blog I have the functionality that allows users who are logged in to be able to select categories of posts they would like to see as a stream on the blog page. So each user only sees posts from categories they have subscribed to and not all categories. I used this code. this is the result. This code works fine, however, I want these...
Order Custom WordPress Posts by Custom Field using Advanced Custom Fields
I am trying to order a set of custom post by time using Advanced Custom Fields (ACF). Using this help page and the WP_Query page from the codex, I've gotten to the code below, but it only sorts by the post title, I want it to sort by the custom field start_time I've created. Here are some of the possible key/values a user can pick: a : 6:00am b : 6...
WordPress custom template not displaying custom HTML, Custom fields, etc
I am developing a custom theme in WordPress, and am trying to put custom HTML and PHP in my home page template. Whenever I am posting code for divs or custom fields in my home page template, they are simply not rendering and displaying on the front end. In the example below, the <div class="col-full"> is not being shown on the front end.
WordPress - Custom Post type, Custom role, Custom Capability
I am stuck in a problem assigning custom capability with custom post type to a custom role. The issue is i want to remove the Add New ( Not with a CSS hack or by unsetting menu item ) option of my custom post type. I have already come across answers that suggest many solutions but none of them works perfectly. Closest to what i want is this : This ...
Import custom database in wordpress with custom user type, custom post type and all other fields
I have an old website which want to do it in wordpress. So I want to import old website's database in new website which I am doing in wordpress. I have custom roles with custom fields in old and new website Also have Custom post-types and each post-type have it's custom fields In both websites is fully same but old website is not on wordpress and I...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.