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

Object method calling for global $wpdb in header.php

I think the problem might lie in: $wpdbinfo = $wpdb->get_results(“SELECT * FROM bo_mytable WHERE id=3”); $wpdb->get_results() returns an array of objects, yet you are referencing a property on $wpdbinfo (->nameinfo). You’ll either want to loop through the $wpdbinfo array, or if you’re certain you’ll get only a single record (possibly a safe assumption if id … Read more

Adding CSS to custom post type admin page causes error

You need to check for the presence of ‘post_type’ as an index of $_GET before using it: if ((isset($_GET[‘post_type’]) && $_GET[‘post_type’] == ‘slide’) || (isset($post_type) && $post_type == ‘slide’)) : Also, you should be using the wp_enqueue_style function instead of echoing your stylesheet at ‘admin_head’: wp_enqueue_style( ‘meteor-slides-admin’, plugins_url(‘/css/meteor-slides-admin.css’, __FILE__), array(), ‘1.0’ ); More information on … Read more

Add quantity field with each product on shop page-wooCommerce [closed]

Here is how i modified my loop/add-to-cart.php to achieve this: <?php /** * Loop Add to Cart * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly global $product; ?> <?php if ( ! $product->is_in_stock() ) : ?> <a href=”https://wordpress.stackexchange.com/questions/125946/<?php echo … Read more