How to add a data attribute to a WordPress menu item

Specifically editing the code you provided in the original question: add_filter( ‘nav_menu_link_attributes’, ‘wpse121123_contact_menu_atts’, 10, 3 ); function wpse121123_contact_menu_atts( $atts, $item, $args ) { // The ID of the target menu item $menu_target = 123; // inspect $item if ($item->ID == $menu_target) { $atts[‘data-toggle’] = ‘modal’; } return $atts; }

400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook

I think the only thing missing here is that you need to move add_action(‘wp_ajax_nopriv_ajaxlogin’,’ajax_login’); outside ajax_login_init. That code registers your Ajax handler, but when you only run it on wp_enqueue_scripts, it’s already too late and wp_ajax_nopriv_ hooks are already run. So, have you tried something like this: function ajax_login_init(){ if ( ! is_user_logged_in() || ! … Read more

Ajax call always returns 0

Could you place the action (ajaxConversion) in your Data and check? jQuery.ajax({ type:”POST”, url: ajaxurl, data: { action: “ajaxConversion”, amount: amountToConvert }, success:function(data){ alert(data); }, error: function(errorThrown){ alert(errorThrown); } });

Add multiple custom fields to the general settings page

Well the second bit of code is technically the correct way to do it. However, at the end of the add_settings_field() you can pass arguments. Please view the WordPress Add_Settings_Field function reference. This will help you in getting the best understanding of how the add_settings_field() function really works. Now, with that said, you could use … Read more

How to override parent functions in child themes?

You should run the code after theme setup. function osu_twentyten_continue_reading_link() { return ‘ <a href=”‘. get_permalink() . ‘”>’ . __( ‘Read on <span class=”meta-nav”>&rarr;</span>’, ‘twentyten-child’ ) . ‘</a>’; } function osu_twentyten_auto_excerpt_more( $more ) { return ‘ &hellip;’ . osu_twentyten_continue_reading_link(); } function my_child_theme_setup() { remove_filter( ‘excerpt_more’, ‘twentyten_auto_excerpt_more’ ); add_filter( ‘excerpt_more’, ‘osu_twentyten_auto_excerpt_more’ ); } add_action( ‘after_setup_theme’, ‘my_child_theme_setup’ … Read more

Why use if function_exists?

Checking to see if built in WordPress functions exist before calling them is for backward compatibility which IMHO is not needed. So if you see if ( function_exists( ‘register_nav_menus’ ) ) the theme author is supporting versions earlier than 3.0. You still sometimes see if ( function_exists( ‘dynamic_sidebar’ ) ) Why? I couldn’t tell you … Read more