CGAdmin
Forum Replies Created
-
Forum: Hacks
In reply to: Dynamic menu options based on userOkay, 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_itemfunction. 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
In reply to: Dynamic menu options based on userI stumbled upon the
wp_nav_menu_itemsfilter as I was nosing through theWalker_Nav_Menuand 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
In reply to: Manual link to new php file outside of loop?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
In reply to: Manual link to new php file outside of loop?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
In reply to: Manual link to new php file outside of loop?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 aninclude()call, but this is supposed to be a link, not an include.Am I even making sense?
Forum: Fixing WordPress
In reply to: Pages helpThe 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
In reply to: Manual link to new php file outside of loop?I assume this has something to do with The Loop function. It surprises me that nobody has encountered this issue before…
Forum: Networking WordPress
In reply to: [Feedback] WordPress Menu/widgets MultisiteGood 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
In reply to: [Feedback] WordPress Menu/widgets MultisiteI’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_blogcall 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?
Caveat:
It seems that the
wp_ms_postsdatabase does not get updated as frequently as thewp_v_postsdatabase? Or perhaps I messed up my loading function as I’ve been playing with all of the innards? Regardless, switchingwp_ms_poststowp_v_postsseems 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
In reply to: Unable to enqueue jQueryI 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/ and the JS file is located at 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',