Add custom attributes to menu items without plugin

Filter nav_menu_link_attributes: add_filter( ‘nav_menu_link_attributes’, ‘wpse_100726_extra_atts’, 10, 3 ); function wpse_100726_extra_atts( $atts, $item, $args ) { // inspect $item, then … $atts[‘custom’] = ‘some value’; return $atts; } This works with WordPress < 3.6: add_filter( ‘walker_nav_menu_start_el’, function( $item ) { $parts = explode( ‘>’, $item ); $out = array (); foreach ( $parts as $i => … Read more

How to get a different mobile menu than desktop menu in the twentytwelve child theme

As recommended in a similar post: https://wordpress.stackexchange.com/a/156494/74343 1.) Create the menus as you want them, and name them as you like, as an example “mobile-menu” and “desktop-menu“. 2.) In your child theme in the header.php you could switch according to the wp_is_mobile() flag like this: if ( wp_is_mobile() ) { wp_nav_menu( array( ‘menu’ => ‘mobile-menu’ … Read more

How do I add the data-toggle=”modal” data-target=”#myModal” attribures to a WP Nav bar?

PHP way: Add the following to your functions.php file. Filter nav_menu_link_attributes: add_filter( ‘nav_menu_link_attributes’, ‘my_menu_atts’, 10, 3 ); function my_menu_atts( $atts, $item, $args ) { // Provide the id of the targeted menu item $menu_target = 123; // inspect $item if ($item->ID == $menu_target) { // original post used a comma after ‘modal’ but this caused … Read more

How to Move the Author Metabox into the “Publish” metabox?

I somewhat suck with admin stuff so test this carefully. I had some issues with users not coming up in dropdown, but it fails with default meta box as well – probably because of my messed up test stack. add_action( ‘admin_menu’, ‘remove_author_box’ ); add_action( ‘post_submitbox_misc_actions’, ‘author_in_publish’ ); function remove_author_box() { remove_meta_box( ‘authordiv’, ‘post’, ‘normal’ ); … Read more

How do I pass an argument to my custom walker?

Native walker are triggered with walk() method and are not set up to receive data on creation. You can define custom property and constructor method for this purpose: class plus_walker extends Walker_Nav_Menu { var $refine; function __construct($refine) { $this->refine = $refine; } } //stuff ‘walker’ => new plus_walker(‘review’); After this you can access your custom … Read more

Using filters to change href of nav menu page link

You are on right track, with few minor kinks. You need to modify $atts and return it. Any arguments after the first one are provided for information and should not be changed. You need to tell add_filter() that you expect more than one argument. The example with some debug code would be along the lines … Read more

Large WP 3.0 menu times out and won’t save

You can always try to split your menu into 2 separate menus and then just display them next to each other in your theme. It’s far from perfect and doesn’t help a bit in understanding the root of your problem but it could help. You can use it as temporary workaround to GTD before deadline … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)