Insert Widget option into mark-up with register_sidebar

First you will replace this line <div id=”%1$s” class=”widget %2$s” data-custom-title=””> with <div id=”%1$s” class=”widget %2$s” data-custom-title=”DCT”> Now add the filter in your functions.php file. add_filter( ‘widget_display_callback’, ‘add_custom_data_to_before_widget’, 10, 3 ); function add_custom_data_to_before_widget( $instance, $widget_class, $args ) { if ( ! empty( $instance[‘title’] ) && ! empty( $instance[‘custom-title’] )) { $args[‘before_widget’] = str_replace(‘DCT’, sanitize_text_field ( … Read more

How to make a widget expand wider than the column width when editing its settings in the admin

This can be set by passing arguments to the $control_options of the parent widget constructor, which is the fourth argument. Here is an example constructor: class Custom_Widget extends WP_Widget { /** * Sets up the widgets name etc */ function __construct() { $widget_options = array( ‘description’ => __( ‘Featured Pages Widget.’, ‘affiliate’ ) ); $control_options … Read more

Including Custom Post Type posts in a page template contextually (or should I widget?)

Custom Archive Page What you’re describing is a custom archive page. https://www.google.com/search?q=custom+archive+page https://codex.wordpress.org/Creating_an_Archive_Index Child Theme Forget widgetised areas. They’re not necessary based on what you described. Simply fork (copy and manipulate) your archives template page by using using a child theme rather than directly editing the parent theme (edits won’t survive theme updates). https://codex.wordpress.org/Child_Themes Featured … Read more

How to add a class to Tag cloud widget link?

You only want to add a class name based on the counts. Your above code looks like you may have copy/pasted from somewhere but you don’t need all that. I just tested this with wp_generate_tag_cloud_data (#L869) and wp_tag_cloud() and it’s working. Unfortunately for a basic test site like mine, the small count represents the largest … Read more