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’);

Can’t get JS code to work with shortcode

You need to return the Shortcode generated string, not echo, like this: function gg_product_front_end() { wp_register_script( ‘gg_loadProducts_frontEnd’, plugins_url( ‘js/front_end.js’, __FILE__ ), array( ‘jquery’ )); wp_enqueue_script( ‘gg_loadProducts_frontEnd’ ); return ‘<p id=”test”>Test!</p>’; } Also, you need to call the JavaScript function, like this: function gg_loadProducts_frontEnd() { console.log( ‘Test!’ ); } gg_loadProducts_frontEnd(); Otherwise Test! will not be logged … Read more

shortcode to output multiple images urls from media library id

Try this function image_thingy($atts) { // Merge attribtes from shortcode with defaults extract(shortcode_atts(array( ‘id’ => 1, ), $atts)); // Extract id’s from shortcode attributes and convert into an array $ids = explode(‘,’,$atts[‘id’]); $output=””; // Variable that holds the shortcode output, at the end this will be returned // Loop through ids and fetch urls, and … 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

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

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