Title: CGAdmin's Replies | WordPress.org

---

# CGAdmin

  [  ](https://wordpress.org/support/users/cgadmin/)

 *   [Profile](https://wordpress.org/support/users/cgadmin/)
 *   [Topics Started](https://wordpress.org/support/users/cgadmin/topics/)
 *   [Replies Created](https://wordpress.org/support/users/cgadmin/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/cgadmin/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/cgadmin/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/cgadmin/engagements/)
 *   [Favorites](https://wordpress.org/support/users/cgadmin/favorites/)

 Search replies:

## Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)

 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Dynamic menu options based on user](https://wordpress.org/support/topic/dynamic-menu-options-based-on-user/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/dynamic-menu-options-based-on-user/#post-2977019)
 * Okay, I have more problems for anyone who is capable of assisting.
 * The above code will either allow me to append the new menu items on the front
   or back of the menu and only on the top level. This suggests the need to re-work
   the walker to go back through and sort the menu once again.
 * Furthermore, the only method I can find for setting the parent ID (thus allowing
   new submenu items) is by using the `wp_update_nav_menu_item` function. However,
   this only results in the new menu items being listed as “pending” on the admin
   GUI menu interface.
 * So my issues are the following:
    - Need to add dynamic links/buttons to the menu
    - Need ability to sort these new links
    - Need ability to place certain links as submenu
 * Any help would be much appreciated!
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Dynamic menu options based on user](https://wordpress.org/support/topic/dynamic-menu-options-based-on-user/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/dynamic-menu-options-based-on-user/#post-2977002)
 * I stumbled upon the `wp_nav_menu_items` filter as I was nosing through the `Walker_Nav_Menu`
   and realized that this could be used to add dynamic menu options. It’s not pretty
   and I’m sure I have done something screwy with the PHP/HTML mix, but it seems
   to work. So for those who are looking to do something similar, here ya go:
 *     ```
       function new_nav_menu_items($items) {
         global $user_login;
   
         $dynamic_link = '<li class="home"><a href="' . network_home_url('/') . $user_login . '/link-1/">Link 1 Text</a></li>';
         $items = $dynamic_link . $items;
         return $items;
       }
       add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Manual link to new php file outside of loop?](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/#post-2957165)
 * Ohh… It didn’t even dawn on me that I could create a template.
 * All I did was add the template identification code to the top of my previously
   existing my_file.php and simply pointed the appropriate blank page in the Admin
   section to this proper template.
 * A little silly if you ask me, but it works.
 * Thanks!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Manual link to new php file outside of loop?](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/#post-2957163)
 * I suppose I’m trying to figure out a way to have either of the following code
   effects occur upon clicking the “Register” link:
 *     ```
       get_template_part('register');
       include('/register.php');
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Manual link to new php file outside of loop?](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/#post-2957162)
 * I’m currently involved in development on a localhost so there are no public pages
   available at this point.
 * My solution at this point has been to simply create a page from the admin screen
   with the desired content within, but this limits my ability to add code when 
   applicable.
 * The problem is not with the `network_home_url()` (and yes, this is multisite),
   but with the inability to have the index.php direct to the href link. For example,
   when I attempt to link to a separate file: `<a href="<?php network_home_url();?
   >/register.php">Register</a>` I get a 404 error. I am able to bring up this file
   using an `include()` call, but this is supposed to be a link, not an include.
 * Am I even making sense?
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Pages help](https://wordpress.org/support/topic/pages-help-4/)
 *  [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/pages-help-4/#post-2975426)
 * The first step is to ensure within your admin panel under Settings -> Reading,
   the Front Page Displays option is set to “Your latest posts” rather than “A static
   page”.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Manual link to new php file outside of loop?](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/manual-link-to-new-php-file-outside-of-loop/#post-2957159)
 * I assume this has something to do with The Loop function. It surprises me that
   nobody has encountered this issue before…
 *   Forum: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
   
   In reply to: [[Feedback] WordPress Menu/widgets Multisite](https://wordpress.org/support/topic/feedback-wordpress-menuwidgets-multisite/)
 *  [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [14 years ago](https://wordpress.org/support/topic/feedback-wordpress-menuwidgets-multisite/#post-2681187)
 * Good looking sites.
 * You can change your code to the following and get the same function if you care
   about keeping your code as short as possible:
 *     ```
       switch_to_blog(1);
   
       echo theme_get_menu(array(
       'source' => theme_get_option('theme_menu_source'),
       'depth' => theme_get_option('theme_menu_depth'),
       'menu' => 'primary-menu',
       'class' => 'art-hmenu'
       ));
   
       restore_current_blog();
       ```
   
 *   Forum: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
   
   In reply to: [[Feedback] WordPress Menu/widgets Multisite](https://wordpress.org/support/topic/feedback-wordpress-menuwidgets-multisite/)
 *  [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [14 years ago](https://wordpress.org/support/topic/feedback-wordpress-menuwidgets-multisite/#post-2681185)
 * I’ve been messing with this sort of issue for pretty much the whole day and I
   think I have figured out how to create a basic menu for each “child” site based
   on one “master” menu on the main site (or even any other site you choose to place
   it).
 * It might take us a bit of hashing to get it to work right because I am in the
   infancy of the operation, but I’m pleased with my results so far.
 * The key is to utilize the same underlying theme for all sites (which it appears
   you are doing to “brand” the child sites as I am). I personally like to use two
   custom menus: public-menu and user-menu. Obviously one is for logged in users
   and the other is for anonymous users.
 * What we need to do is tell each child site where to look as it builds its menu
   structure. I’m sure you have discovered that even if you name all the menus on
   each child site the same, it creates its own instance of that menu (which defaults
   to blank). As a caveat, I have been messing around with changing the default 
   structure of the menus as well, but haven’t had much luck.
 * Anyway, in the header when you call your custom menu, add a `switch_to_blog` 
   call in before you load the menu. This will make the server call up the same 
   menu on all child sites. The unfortunate part is that the user then is unable
   to add new menu options or make changes. I’m still working on that part. The 
   cool part is that the child sites aren’t required to have any menus defined at
   all.
 * Here is the code I have in my header:
 *     ```
       <?php if (is_user_logged_in()) {
       	switch_to_blog(1);
       	wp_nav_menu(array(
       		'echo' => true,
       		'theme_location' => 'user-menu',
       		'container_class' => 'nav-center'
       	));
       	restore_current_blog();
       } else {
       	switch_to_blog(1);
       	wp_nav_menu(array(
       		'echo' => true,
       		'theme_location' => 'public-menu',
       		'container_class' => 'nav-center'
       	));
       	restore_current_blog();
       } ?>
       ```
   
 * Does this help?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Multisite Latest Posts Widget] [Plugin: Multisite Latest Posts Widget] Updated for WP 3.4.1](https://wordpress.org/support/topic/plugin-multisite-latest-posts-widget-updated-for-wp-341/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [14 years ago](https://wordpress.org/support/topic/plugin-multisite-latest-posts-widget-updated-for-wp-341/#post-2958793)
 * Caveat:
 * It seems that the `wp_ms_posts` database does not get updated as frequently as
   the `wp_v_posts` database? Or perhaps I messed up my loading function as I’ve
   been playing with all of the innards? Regardless, switching `wp_ms_posts` to `
   wp_v_posts` seems to work better. Feedback on whether this is just my site or
   everyone’s would be much appreciated.
 * I also noticed that the links were not working correctly. Line 85 needs to be
   adjusted as follows:
    `switch_to_blog($post->blog_id);`
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Unable to enqueue jQuery](https://wordpress.org/support/topic/unable-to-enqueue-jquery/)
 *  Thread Starter [CGAdmin](https://wordpress.org/support/users/cgadmin/)
 * (@cgadmin)
 * [14 years ago](https://wordpress.org/support/topic/unable-to-enqueue-jquery/#post-2956529)
 * I just got to thinking, the enqueue function references a JS file located at “/
   js/login.js”. We are creating a multisite network and have been doing much of
   the testing on one of the “child” sites. This means the function was looking 
   in the wrong directory for the JS file since the architecture is set up as [http://mysite.com/child/](http://mysite.com/child/)
   and the JS file is located at [http://mysite.com/js/login.js](http://mysite.com/js/login.js).
 * For those with the same stupid hat on as me, be sure to include a “../” in front
   of url references when working with multisite installations! (Otherwise, the 
   code is just fine.)
 * New line in function should be:
 * `get_template_directory_uri() . '../js/login.js',`

Viewing 11 replies - 1 through 11 (of 11 total)