Tag Info

New answers tagged

1

I do think that the days of creating a separate theme for mobile users are long gone. With proper planning and layout you can use one theme on desktops, laptops, tablets and mobile devices I would tackle this is a much different way. Firstly, I would create my theme in such a way it is responsive on according to the required screensize like normal. For ...


0

Create 2 menus. One for display on mobiles and one as a default for desktops. Add this code in your header.php or you could use a hook in your functions file. <?php if ( is_wp_mobile() ) { wp_nav_menu( array( 'theme_location' => 'mobile-menu' ) ); } else { wp_nav_menu( array( 'theme_location' => 'desktop-menu' ) ); } ?> Or you could ...


1

Its quite odd to have two themes running like you describe, but I think we can figure this out. In both themes, wherever your menu is printed (probably header.php) you'll need some code like this that chooses the correct menu, then prints it: $desktop_theme_name = 'Desktop Theme Name'; // Replace this with the name of the desktop theme $mobile_theme_name = ...


0

I found this filter online a while ago when I had similar issue. I wanted to display all children pages that were set in Appearances -> menus in the backend of wordpress. I only wanted to show the children of the current page, without using get_children. I would give credit to whoever wrote this beauty, but I can't find the source. This filter adds an extra ...


0

You will get the nav_menu_items from wp_term_relationship in correct order. if you want to confirm there order by knowing there order number... u will get the object id of each item from the previous table and search for that id in wp_posts. then there will be column for that particular row named menu_order. so that u can get the actual order number.


1

You can achieve this using the wp_nav_menu_items hook. Let's have a look at the following piece of code which shows the login/logout link on the primary menu location. add_filter( 'wp_nav_menu_items', 'wti_loginout_menu_link', 10, 2 ); function wti_loginout_menu_link( $items, $args ) { if ($args->theme_location == 'primary') { if ...


0

This looks like it would get you pointed in the right direction: http://stackoverflow.com/questions/6215797/wordpress-post-id-in-wp-nav-menu


0

Use the last-child pseudoclass in the CSS: .mainnav li:last-child { /* your code */ }


0

You can add classes natively via interface in admin. Open Screen Options (top right of the screen) and check CSS Classes. I don't remember if class applies to link itself, but you can always target link inside container with CSS (.class a).


0

Found a fix. Seems pagination is breaking the display of the the Pages hierarchy in the metabox. Here is the fix to disable page pagination in the nav menu metabox https://core.trac.wordpress.org/attachment/ticket/18282/18282-disable-nav-menu-pagination.patch Thanks


0

Sometimes i find wordpress can be quite finiky when it comes to referencing files within the plugin. Specifying a full path seems to fix the problem. Try replacing... market_admin/icon.png With... /wp-content/plugins/your-plugin-name-goes-here/your-file-name-goes-here.png


0

What about using jQuery to insert the unique code to your CTA menu class or item ID? Something like: // generate your unique codes in jQuery var mycode = your_random_code_function() // or an array of codes // then… var myhref = $("body.landingpage .navbar-nav .cta a").attr("href"); $("body.landingpage .navbar-nav .cta a").attr("href", ...


0

I solved this way: in header.php (of your theme) I searched for: 'link_before' => '', 'link_after' => '', and replaced with: 'link_before' => '<script>var ...


0

It is string escape problem with PHP Syntax Correct Code: <?php if ( is_user_logged_in() ) { echo ''; } else { echo '<a onclick="ppOpen(\'#login_panel\', \'800\',1)" href="javascript:void(0)">Entrar</a>'; } ?>


1

Have you tried adding the is_page() conditional like this: if( has_nav_menu( 'smone-menu', 'responsive' ) && is_page(array( 10,11 ))) {


0

An alternative, at least, is to use this plugin: Auto Submenu WordPress can only automatically add new top-level pages to menus. With Auto Submenu, new child pages will also be automatically added to menus.


0

You can use wp_get_nav_menu_items(). Here's a sample function: <?php function my_get_menu_item_name( $loc ) { global $post; $locs = get_nav_menu_locations(); $menu = wp_get_nav_menu_object( $locs[$loc] ); if($menu) { $items = wp_get_nav_menu_items($menu->term_id); foreach ($items as $k => $v) { // ...


0

One option would be to make custom templates for each menu that you have. (That refers to the theme locations check box) Then on every page, you choose the template that you want it to use and it will also use the menu associated with that template. https://codex.wordpress.org/Page_Templates It gives you the same result I think you are looking for but ...


0

Finally the answer is simple: $menu_name = 'your menu';//name,id,slug wp_delete_nav_menu($menu_name);


0

wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' , 'depth' => 1) ); you can use depth parameter for this.. Click here! More Info: child theme Create child theme and copy code from header.php of parent theme then replace the code wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' ) ); with the ...


0

I tried your code it works perfectly fine for me, to give output as: <div class="container_class" id="container_id"> <ul class="menu_class" id="menu_id"> <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-154"><a href="http://www.ohitsfunny.com/category/funny/">Funny</a></li> <li ...


0

You say that you know about show_in_menu parameter for register_post_type() but it seems like you missed the options for this parameter: 'false' - do not display in the admin menu 'true' - display as a top level menu 'some string' - If an existing top level page such as 'tools.php' or 'edit.php?post_type=page', the post type will be placed as a sub menu of ...


0

WordPress allows the addition of extra nav menus. Add this to your child themes functions file: register_nav_menus( array( 'secondary_menu' => 'My Second Menu' ) ); Add this to your header.php file or the file where you want to display your extra nav menu. <nav id="site-navigation" class="main-navigation" role="navigation"> ...


0

I've found what I was looking for in wpengineer.com It's made by the $menu as global variable.


0

I think using a plugin for this is better, so you can keep the functionality even if you change themes in the future. Check out this plugin. It does what you want, but slightly differently than how you mocked it up. https://wordpress.org/plugins/page-specific-menu-items/ If this helps, please up vote or accept as the answer. Thanks!


0

According to the Codex, wp_nav_menu() has a couple parameters to add HTML or entities before and after the generated HTML. The parameters you want is link_before and link_after and to get the effect you're after looks like this: 'link_before' => '<span class="left_arrow"></span><span class="middle_text">', 'link_after' => ...


1

If I understand correctly, you want links with submenus to have an attribute of aria-haspopup. If this is correct, you should be able to do so using the nav_menu_link_attributes filter (WP 3.6 and above). You can also get around the necessity of having to write a custom Walker to check if an item has children by checking its css classes in the filter. ...


0

You can remove it from the submenu array: function add_my_menu(){ global $submenu; add_menu_page( 'Main Menu', 'Main Menu', 'manage_options', 'main-menu-settings', 'main_menu_settings'); add_submenu_page( 'main-menu-settings', 'Sub Menu', 'sub menu', 'manage_options', 'sub-menu', 'sub_menu_settings'); unset( $submenu['main-menu-settings'][0] ...


0

[Update] Solution found: I was looking for 'items_wrap' => '<ul id="%1$s" class="%2$s" role="menu" >%3$s</ul>' <?php wp_nav_menu( array( 'menu' => 'menu', 'theme_location' => 'menu', 'items_wrap' => '<ul id="%1$s" class="%2$s" role="menu" ...


0

A filter solution could be the nav_menu_css_class filter. A CSS solution could be to use the body_class to make more specific css rules.


1

Here I have copied the Class used from the WordPress Core for you and then updated the Class name, Updated_WP_Nav_Menu_Widget that it is extending and used the widgets_init() action to register the widgit. /** * Navigation Menu widget class * * @since 3.0.0 */ class Updated_WP_Nav_Menu_Widget extends WP_Widget { function __construct() { ...


0

The code you are using only gets the children of a parent page. It first checks to see in which page you are. If you are in a child page it uses the parent ID to print it's children. If you're in a parent page then it just looks for it's children using the post ID. Neither case it prints the actual parent. I edited the code so that it will print the parent. ...


1

Good that it works. If it's for a client or if you just want cleaner code, you can do it as @Tom J Nowell suggested. Add a custom menu item, link it to nowhere or anywhere. Find out the menu item ID (every item has one), and then target that ID with jQuery. $("#menu-item-num").on("click", function(e){ e.preventDefault(); // olark code here ...


1

Solution #1 (not ideal, but it works): // Live Chat Utility Link add_filter( 'wp_nav_menu_items', 'live_chat_utility_link', 10, 2 ); function live_chat_utility_link ( $items, $args ) { if ( $args->theme_location == 'utility' ) { $items .= '<li><a href="javascript:void(0);" onclick="olark(\'api.box.expand\')" class="livechat">Live ...


0

Put this function into your theme's function.php file. function is_tree($pid) { // $pid = The ID of the page we're looking for pages underneath global $post; $anc = get_post_ancestors( $post->ID ); foreach($anc as $ancestor) { if(is_page() && $ancestor == $pid) { return true; } } ...


2

I think use Custom Walker. First register a custom navigation menu for this list in your theme’s functions.php class WP_Walker extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<div id='mega'><ul class='sub-menu'>\n"; } ...


0

Well, the answer depends on what you mean by "custom dropdown only for the first menu item which is different from the other item dropdowns" - different how? If it's just stylistic, that extra class should be enough. You just have to make sure the css for it is specific enough to override the defaults. So if your css selectors on the other dropdowns are ...


0

Navigation menus are technically terms, but there is pretty rich API around theme to abstract that away. wp_get_nav_menus() should do it. :)



Top 50 recent answers are included