Additional classes `undefined` after saving post in Gutenberg

After about an hour of trial and error, I found that the outmost <Fragment> was the culprit. But I still can’t figure out why! Replacing it with <div> fixed it. So the code looks like this now: edit: (props) => { const {attributes, setAttributes} = props; const headingBgOverlay = Util.getBgOverlay(attributes, ‘heading’); const bodyBgOverlay = Util.getBgOverlay(attributes, … Read more

How to add custom table style for table block in gutenberg editor

The register_block_style function is what you’ll want. The basic implementation is register_block_style( ‘core/table’, array( ‘name’ => ‘my-table-style’, ‘label’ => ‘My Table Style’, ) ); When you select the style, it will add the is-style-my-table-style class to the block, which you can style using your style.css or other stylesheet. There are two other implementations, where you … Read more

Using WordPress PHP code, how to bulk delete only 100 subscribers at a time from thousands of users?

Here you will find all parameters supported by get_users(). $blogusers = get_users( [ ‘role’ => ‘subscriber’, // limit the number of rows returned ‘number’ => 100, ] ); foreach ( $blogusers as $user ) { wp_delete_user( $user->ID ); } Or return only ID: // $blogusers is array of IDs $blogusers = get_users( [ ‘role’ => … Read more

How to use html inside a functions.php code?

function misha_loadmore_ajax_handler() { $args = json_decode ( stripslashes ( $_POST[ ‘query’ ] ), true ); $args[ ‘paged’ ] = $_POST[ ‘page’ ] + 1; $args[ ‘post_status’ ] = ‘publish’; query_posts ( $args ); if( have_posts () ) :while ( have_posts () ): the_post (); ?> <div class=”griditem”> <a class=”producturl” href=”<?php the_permalink (); ?>”> <div class=”productimagewrapper”> … Read more

WPDB: Update table

Now I have learned that the way I change the database is not safe regarding SQL injection. So I wonder where/how did you learn that? And other than that you should check if those two POST variables are actually set, your toggle_status() code looks fine to me, and $wpdb->update() is an easy way to update … Read more

Using a custom shortcode from within the template of a shortcode plugin

If I understand it correctly, inside the shortcode template, you could do something like this: echo do_shortcode( ‘[ta-intentclicks-link url=”‘ . esc_url( $list_item[‘link’] ) . ‘”]Visit website[/ta-intentclicks-link]’ ); But then, instead of having to use do_shortcode(), you could actually simply call the shortcode callback from the (shortcode) template ( which then eliminates the need to find … Read more