New answers tagged

1

WordPress 5.8 added the ability to add Blocks to sidebars. Blocks do not use the title and markup defined for a sidebar. They just use the normal HTML they would use in the editor. “Legacy” widgets can still be added, and should still have the option to enter a title and use the markup defined for that widget area. WordPress is moving towards using blocks ...


0

But I see no way to add a title unless using legacy widgets. Correct, legacy old style widgets have titles, normal blocks do not because they are not widgets. Note that old style widgets are actually blocks of type core/legacy-widget. Everything is a block. Has this field been removed? No, it was never there to begin with. It's not that blocks can now be ...


0

As far as I am aware, there is no built-in way to get all the posts in a site that contain a specific block. Two potential things you could do: You can use the has_block() function to determine if a specific post has a specific block. (there is also a more accurate parse_blocks() function available). You could loop over all content and fine posts that ...


0

Only Blocks appear in the block editor. A recent version of WordPress added the ability to add Blocks to widget areas, but not the ability to add Widgets to posts. You have registered a Widget, which can only be added to widget areas. To create a widget that can be added anywhere that Blocks can be used, you need to create a Block: https://developer....


0

The $atts in your template part (templates/show-taxonomy.php) that you passed to shortcode_atts() is not defined, so you need to define it by passing it via the third parameter for get_template_part() like this: get_template_part( 'templates/show-taxonomy', '', array( 'atts' => $atts ) ); Then in the template part, use $args['atts'] to access the ...


1

Based on the accepted answer I solved my problem with this function, hope it helps, and thanks, Mridul Aggarwal. function is_active_sidebar_with_content( $sidebar ) { $sidebars = wp_get_sidebars_widgets(); if ( isset( $sidebars[ $sidebar ] ) && ! empty( $sidebars[ $sidebar] ) ) { return true; } return false; }


1

You're right. I didn't notice it before ! If you look at the code, you can see that Widgets are now showed from /wp-includes/widgets/class-wp-widget-block.php which extends /wp-includes/class-wp-widget.php The first file is a new one introduced in WP 5.8. In there you can see that the widget is now displayed through widget_block_content filter which use the ...


0

Actually these types of task is for plugin not for widget. Based on the value of widget instance scripts can be enqueued to footer not in head or just after body tag. Reason behind this is the instance value can be checked inside the function widget of widget class. The function widget is called when a certain dynamic sidebar is called and this must occurs ...


Top 50 recent answers are included