WordPress.org

Ready to get started?Download WordPress

Forums

Network Wide Menus (1 post)

  1. woodplugs6
    Member
    Posted 2 years ago #

    ok, I was really having some trouble with getting a network wide menu rolling on a multisite install I was creating.
    The problem was that all of the 20 sites in the install were going to be connected via a top menu, but I had no way of creating the menu one time and then exporting just the menu so that I could just import it on all the remaining sites and not have to create it over and over and over.
    I tried WPMU's "network wide menu" plugin to no avail, not because it doesn't work per say, but I believe because my hosting situation didn't allow it. I am hosting this Network of sites @ wpengine, and the way they have things set up didn't allow me to use Ron's plugin.
    I accomplished the export using word press's native export utility. If you select the first option "All" when exporting your site, then along with all the posts and categories etc... you also get menus. It's the only native way to export a menu.
    What you get when you export is a HUGE / LONG xml file that is extraordinarily confusing for newbies. Inside this xml file resides all the info you need, but unfortunately it has all the extra junk that I did not need, and if you are reading this, that you do not need. Here is how to find the stuff you need and get rid of the stuff you don't, in order to end up with an import-able xml file that contains only a working menu.
    ***Mind you, this is my first post on the support forums, and also my first tutorial, so cut me some slack, I am only trying to help! Hopefully this will help others who run into a similar problem.

    ***This method will indeed create a menu for you during the upload. Unlike WPMU's plugin, you do not have to have the menu already existing for this to work. But if you do have it already created, it will add the new menu items to any existing ones. This is only if you have a menu, previously created, with the exact same name. My advice, import this menu to the intended site before you crate a menu using that name. If its already partially there or something, just delete it :)

    1st: create the menu you want to use as a site wide menu. Do this via the wordpress 3.0+ menu system, and name it something that you can remember. I will use the name "network" for this example.

    2nd: export you sites data using the native export tool located in tools>export from the dashboard of your site. *be sure to use the default setting "All content"

    3rd: create the xml file that you will eventually use to import the menu you are about to create. just call it for example "networkMenu.xml" and leave it open on your desktop

    4th: copy and paste this code into networkMenu.xml :

    <?xml version="1.0" encoding="UTF-8" ?>
    <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
    <!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
    <!-- You may use this file to transfer that content from one site to another. -->
    <!-- This file is not intended to serve as a complete backup of your site. -->
    
    <!-- To import this information into a WordPress site follow these steps: -->
    <!-- 1. Log in to that site as an administrator. -->
    <!-- 2. Go to Tools: Import in the WordPress admin panel. -->
    <!-- 3. Install the "WordPress" importer from the list. -->
    <!-- 4. Activate & Run Importer. -->
    <!-- 5. Upload this file using the form provided on that page. -->
    <!-- 6. You will first be asked to map the authors in this export file to users -->
    <!--    on the site. For each author, you may choose to map to an -->
    <!--    existing user on the site or to create a new user. -->
    <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
    <!--    contained in this file into your site. -->
    
    <!-- generator="WordPress/3.3.1" created="2012-02-12 00:29" -->
    <rss version="2.0"
    	xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
    	xmlns:content="http://purl.org/rss/1.0/modules/content/"
    	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    	xmlns:dc="http://purl.org/dc/elements/1.1/"
    	xmlns:wp="http://wordpress.org/export/1.1/"
    >
    <channel>
    
    <generator>http://wordpress.org/?v=3.3.1</generator>
    
    <!--********this is where you lace your unique code**********-->
    
    </channel>
    </rss>

    5th: In the original export file, just after the header comments (around line 30 to maybe 50) you will see a number of blocks of code that all kind of run together. They all start with

    <wp:term><wp:term_id> and end with </wp:term_name></wp:term>

    you are looking for the one that has the name of your menu in it, for the example, ours looks like this:

    <wp:term><wp:term_id>18</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>network</wp:term_slug><wp:term_name><![CDATA[top nav]]></wp:term_name></wp:term>

    You need to copy that block of code, and that one only, and paste it in your networkMenu.xml file, where it says :

    <!--********this is where you lace your unique code**********-->

    6th: using a code editor, use the find functionality (on a mac this is always achieved by pressing command+f) and type this in:

    domain="nav_menu" nicename="network"

    ***replace nicename="network" with nicename="the-name-of-your-menu" and make sure that names of menus with two or more words have dashes separating each word.

    the first instance you pull up will be the first menu item. It will sit in a block of code that looks like this:

    <item>
    		<title>News</title>
    		<link>http://weedub.com/news/</link>
    		<pubDate>Wed, 08 Feb 2012 20:12:53 +0000</pubDate>
    		<dc:creator>weedub</dc:creator>
    		<guid isPermaLink="false">http://weedub.com/?p=39</guid>
    		<description></description>
    		<content:encoded><![CDATA[]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>39</wp:post_id>
    		<wp:post_date>2012-02-08 13:12:53</wp:post_date>
    		<wp:post_date_gmt>2012-02-08 20:12:53</wp:post_date_gmt>
    		<wp:comment_status>closed</wp:comment_status>
    		<wp:ping_status>closed</wp:ping_status>
    		<wp:post_name>news</wp:post_name>
    		<wp:status>publish</wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>1</wp:menu_order>
    		<wp:post_type>nav_menu_item</wp:post_type>
    		<wp:post_password></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="nav_menu" nicename="top-nav"><![CDATA[top nav]]></category>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_type</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_menu_item_parent</wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object_id</wp:meta_key>
    			<wp:meta_value><![CDATA[39]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_target</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_classes</wp:meta_key>
    			<wp:meta_value><![CDATA[a:1:{i:0;s:0:"";}]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_xfn</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_url</wp:meta_key>
    			<wp:meta_value><![CDATA[http://news.weedub.com]]></wp:meta_value>
    		</wp:postmeta>
    	</item>

    Every menu item all start with an <item> tag and end with a closing </item> tag.

    to ensure you don't have any repeat menu items, instead of copying "command+c" just use the cut command "command+x" to remove each menu item from the original file, this way when you go back to find more menu items, the ones you have already found won't be there anymore.

    After removing a menu item, paste it into your new xml file, the go back and press the "find next" option in the original file and cut and paste until you have no more menu items left.

    7th: your final file should look like this:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
    <!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
    <!-- You may use this file to transfer that content from one site to another. -->
    <!-- This file is not intended to serve as a complete backup of your site. -->
    
    <!-- To import this information into a WordPress site follow these steps: -->
    <!-- 1. Log in to that site as an administrator. -->
    <!-- 2. Go to Tools: Import in the WordPress admin panel. -->
    <!-- 3. Install the "WordPress" importer from the list. -->
    <!-- 4. Activate & Run Importer. -->
    <!-- 5. Upload this file using the form provided on that page. -->
    <!-- 6. You will first be asked to map the authors in this export file to users -->
    <!--    on the site. For each author, you may choose to map to an -->
    <!--    existing user on the site or to create a new user. -->
    <!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
    <!--    contained in this file into your site. -->
    
    <!-- generator="WordPress/3.3.1" created="2012-02-12 00:29" -->
    <rss version="2.0"
    	xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
    	xmlns:content="http://purl.org/rss/1.0/modules/content/"
    	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    	xmlns:dc="http://purl.org/dc/elements/1.1/"
    	xmlns:wp="http://wordpress.org/export/1.1/"
    >
    <channel>
    
    <generator>http://wordpress.org/?v=3.3.1</generator>
    
    <wp:term><wp:term_id>18</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>network</wp:term_slug><wp:term_name><![CDATA[top nav]]></wp:term_name></wp:term>
    
    <wp:wxr_version>1.1</wp:wxr_version>
    
    	<item>
    		<title>News</title>
    		<link>http://example.com/news/</link>
    		<pubDate>Wed, 08 Feb 2012 20:12:53 +0000</pubDate>
    		<dc:creator>author</dc:creator>
    		<guid isPermaLink="false">http://example.com/?p=39</guid>
    		<description></description>
    		<content:encoded><![CDATA[]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>39</wp:post_id>
    		<wp:post_date>2012-02-08 13:12:53</wp:post_date>
    		<wp:post_date_gmt>2012-02-08 20:12:53</wp:post_date_gmt>
    		<wp:comment_status>closed</wp:comment_status>
    		<wp:ping_status>closed</wp:ping_status>
    		<wp:post_name>news</wp:post_name>
    		<wp:status>publish</wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>1</wp:menu_order>
    		<wp:post_type>nav_menu_item</wp:post_type>
    		<wp:post_password></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="nav_menu" nicename="network"><![CDATA[top nav]]></category>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_type</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_menu_item_parent</wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object_id</wp:meta_key>
    			<wp:meta_value><![CDATA[39]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_target</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_classes</wp:meta_key>
    			<wp:meta_value><![CDATA[a:1:{i:0;s:0:"";}]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_xfn</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_url</wp:meta_key>
    			<wp:meta_value><![CDATA[http://news.example.com]]></wp:meta_value>
    		</wp:postmeta>
    	</item>
    
            <item>
    		<title>about</title>
    		<link>http://example.com/about/</link>
    		<pubDate>Wed, 08 Feb 2012 20:12:53 +0000</pubDate>
    		<dc:creator>author</dc:creator>
    		<guid isPermaLink="false">http://example.com/?p=39</guid>
    		<description></description>
    		<content:encoded><![CDATA[]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>39</wp:post_id>
    		<wp:post_date>2012-02-08 13:12:53</wp:post_date>
    		<wp:post_date_gmt>2012-02-08 20:12:53</wp:post_date_gmt>
    		<wp:comment_status>closed</wp:comment_status>
    		<wp:ping_status>closed</wp:ping_status>
    		<wp:post_name>about</wp:post_name>
    		<wp:status>publish</wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>1</wp:menu_order>
    		<wp:post_type>nav_menu_item</wp:post_type>
    		<wp:post_password></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="nav_menu" nicename="network"><![CDATA[top nav]]></category>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_type</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_menu_item_parent</wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object_id</wp:meta_key>
    			<wp:meta_value><![CDATA[39]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_target</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_classes</wp:meta_key>
    			<wp:meta_value><![CDATA[a:1:{i:0;s:0:"";}]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_xfn</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_url</wp:meta_key>
    			<wp:meta_value><![CDATA[http://about.example.com]]></wp:meta_value>
    		</wp:postmeta>
    	</item>
    
            <item>
    		<title>contact</title>
    		<link>http://example.com/contact/</link>
    		<pubDate>Wed, 08 Feb 2012 20:12:53 +0000</pubDate>
    		<dc:creator>author</dc:creator>
    		<guid isPermaLink="false">http://example.com/?p=39</guid>
    		<description></description>
    		<content:encoded><![CDATA[]]></content:encoded>
    		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
    		<wp:post_id>39</wp:post_id>
    		<wp:post_date>2012-02-08 13:12:53</wp:post_date>
    		<wp:post_date_gmt>2012-02-08 20:12:53</wp:post_date_gmt>
    		<wp:comment_status>closed</wp:comment_status>
    		<wp:ping_status>closed</wp:ping_status>
    		<wp:post_name>contact</wp:post_name>
    		<wp:status>publish</wp:status>
    		<wp:post_parent>0</wp:post_parent>
    		<wp:menu_order>1</wp:menu_order>
    		<wp:post_type>nav_menu_item</wp:post_type>
    		<wp:post_password></wp:post_password>
    		<wp:is_sticky>0</wp:is_sticky>
    		<category domain="nav_menu" nicename="network"><![CDATA[top nav]]></category>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_type</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_menu_item_parent</wp:meta_key>
    			<wp:meta_value><![CDATA[0]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object_id</wp:meta_key>
    			<wp:meta_value><![CDATA[39]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_object</wp:meta_key>
    			<wp:meta_value><![CDATA[custom]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_target</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_classes</wp:meta_key>
    			<wp:meta_value><![CDATA[a:1:{i:0;s:0:"";}]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_xfn</wp:meta_key>
    			<wp:meta_value><![CDATA[]]></wp:meta_value>
    		</wp:postmeta>
    		<wp:postmeta>
    			<wp:meta_key>_menu_item_url</wp:meta_key>
    			<wp:meta_value><![CDATA[http://contact.example.com]]></wp:meta_value>
    		</wp:postmeta>
    	</item>
    
    </channel>
    
    </rss>

    8th: Go to the dashboard of every site you want the menu in, and use the import option to import your file "networkMenu.xml"
    Now your site will show all the menu items, with their correct names and meta information.

    I know this seems like a lot of work, but it was the only solution I had that enabled me to create the menu once, do a little cutting and pasting once, and then never have to create that menu by hand again. I really really hope this helps, and if I have made any mistakes, please don't hesitate to correct me and help the people that this was intended for.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by woodplugs6
  • This topic is not a support question
  • WordPress version: 3.3.1

Tags