Create shortcode to echo javascript

First of all, it looks like you are trying to enqueue version 2.2.4 of jquery, under the condition that jquery has already been loaded. That doesn’t look good. Secondly, you can’t just echo a script in a shortcode. You must add it to another script using wp_add_inline_script. Like this: function wpse238227_custom_shortcode23() { wp_enqueue_script(‘script-typed’, ‘https://www.example.comwp-content/themes/mediso-v1-03/typed.js’, array(‘jquery’)); … Read more

How to set Noindex to all wordpress pages in a catergory?

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i’ll wrap this function into the YOAST hook for robots. add_filter(‘wpseo_robots’, ‘yoast_no_home_noindex’, 999); function yoast_no_home_noindex($string= “”) { $term_id = get_the_category( $post->ID ); if($term_id[0]->term_id … Read more

Gutenberg: Block SelectControl saves attributes but after a reload of Gutenberg it loads its defaults. Why?

The reason why the block editor uses the default value — for the max_level (“Maximum level”) attribute only — instead of the one parsed from the (block comment delimiter in the) saved post content, is because in the parsed/saved attributes, max_level is invalid. Why is it invalid: Because the type of the attribute (value) doesn’t … Read more

How can I remove the WordPress-Version (?ver=5.x) from my plugin

Change the 4th parameter from false to null. wp_enqueue_script( ‘myID’, $url, array( ‘jquery’ ), null, true ); From the wp_enqueue_script() documentation: $ver (string|bool|null) (Optional) String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version … Read more

Hide certain widgets from specific user roles in admin

You have to check for Roles and Capabilities in the action hook widgets_init and proceed accordingly. add_action( ‘widgets_init’, ‘remove_widgets_wpse_89138’ , 15 ); function remove_widgets_wpse_89138() { // http://codex.wordpress.org/Function_Reference/is_admin if( !is_admin() ) return; // Grab current user info global $current_user; // Check for specific user /* $username = $current_user->user_login; if( ‘the_user_login’ != $username) return; */ // Check … Read more

How to calculate total number of comments made by a particular user

You can use get_comments function to retrive the comment count.Pass the user id of perticuler user as an argument. $args = array( ‘user_id’ => 1, // use user id ‘count’ => true //return only the count ); $comments = get_comments($args); echo $comments Please refer below link for more information. http://codex.wordpress.org/Function_Reference/get_comments