WordPress menu deletes when trying to add a hook

I don’t think there’s wp_nav_menu action. Perhaps you want the wp_nav_menu filter (doc)? function custom_novice_menu($args) { if( ‘primary’ == $args[‘theme_location’] ) // only apply to the right menu { $args[‘container’] = ‘div’; } return $args; } add_filter(‘wp_nav_menu’, ‘custom_novice_menu’);

How to make unique add_filter to the_content of specific page template files – so each template gets its own addition

You can get the name from the global $template. I don’t know of a way to get it with an API call instead of a global, but such is life. function floridacontent( $content ){ global $template; $name = basename( $template, ‘.php’ ); if( ‘page-florida’ == $name ){ $content .= ‘Forida added content’; } return $content; … Read more

Display only custom post type count for current author on the “At a Glance” dashboard widget

I think what you’re after is: // The user is logged, retrieve the user id (this needs to go above your foreach) $user_ID = get_current_user_id(); // Now we have got the user’s id, we can pass it to the foreach of your function(this needs to go into your foreach: echo ‘<li>Number of ‘.$post_type->name.’ posts published … Read more

Query children and parent title

I’m not entirely sure if I get your problem correctly, because of the “it’s not an option part”, but… You get children pages of page with ID = 2, so it looks like you want to display the title of that page. If so, then this code will solve your problem: <?php $args = array( … Read more

Display a text message if the shortcode is found?

Try this: <article> <div class=”entry-content”> <?php $current_user = wp_get_current_user(); if ( isset( $current_user->user_email ) ) { echo ‘<p>’ . sprintf( __( ‘%s, here is your client area’, ‘my-theme’ ), $current_user->display_name ) . ‘:</p>’; $output = do_shortcode( ‘[picu_list_collections email=”‘ . $current_user->user_email . ‘”]’ ); // the shortcode returns an empty <ul> tag, if there is no … Read more

What is the criteria for pluggable functions?

Pluggable functions are less elastic than filters/actions. You can have only one pluggable function “active” – so only one plugin can override the core function. And you don’t have much control over which plugin will it be (WP will use the pluggable function that gets defined first). So it won’t be very useful if all … Read more

How can I default to all WordPress roles when parameter is not included in shortcode?

Try this: function profile_counts($atts) { $atts = shortcode_atts( array( ‘metakey’ => ”, ‘metavalue’ => ”, ‘userrole’ => ”, ), $atts ); $user_ids = get_users( array( ‘meta_key’ => $atts[‘metakey’], ‘meta_value’ => $atts[‘metavalue’], ‘role__in’ => wp_parse_list( $atts[‘userrole’] ), ‘fields’ => ‘ID’, // retrieve just the IDs ‘count_total’ => false, // no need for FOUND_ROWS() ) ); return … Read more

What is the $context in remove_meta_box function?

The context within the screen IS where the boxes should display. Available contexts vary from screen to screen. Post edit screen contexts include ‘normal’, ‘side’, and ‘advanced’. Comments screen contexts include ‘normal’ and ‘side’. Menus meta boxes (accordion sections) all use the ‘side’ context. Global default is ‘advanced’. So it is the place you are … Read more