How to remove the parentheses from the category widget

Add this code to your functions.php file and it will remove the parentheses and surround the post count with a span with a class to easily style it. function categories_postcount_filter ($variable) { $variable = str_replace(‘(‘, ‘<span class=”post_count”> ‘, $variable); $variable = str_replace(‘)’, ‘ </span>’, $variable); return $variable; } add_filter(‘wp_list_categories’,’categories_postcount_filter’); ++Bonus In the archive widget, if … Read more

Is there a way to add more tags to the tag cloud?

The tag cloud widget uses wp_tag_cloud() to display the tags, which defaults to 45 tags. Source: https://developer.wordpress.org/reference/functions/wp_tag_cloud/ One can use the widget_tag_cloud_args filter to change this number (and any other arguments passed to wp_tag_cloud(). Here’s an example: function wpse_235908_tag_cloud_args( $args ) { $args[‘number’] = 70; // the number of tags you want to display. return … Read more

Register multiple sidebars

You just need to use the alternate syntax for foreach. From the php manual: The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. … Read more

$post>ID displays wrong post ID

If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag is_page() then you can use $wp_query->get_queried_object_id() like t31os has pointed out so your widget display function should look like this: … Read more

How to Remove All Widgets from Dashboard?

From this Q&A, I’ve learned about the global variable $wp_meta_boxes. And over there is also the code to remove the default meta boxes. After examining the variable, this is the code I wrote to remove all Dashboard Widgets, including the ones added by plugins: add_action(‘wp_dashboard_setup’, ‘wpse_73561_remove_all_dashboard_meta_boxes’, 9999 ); function wpse_73561_remove_all_dashboard_meta_boxes() { global $wp_meta_boxes; $wp_meta_boxes[‘dashboard’][‘normal’][‘core’] = … Read more

Different widgets on different page templates?

You will need to create more sidebars in your functions.php file and then edit the page templates to call the sidebar you want. Adding sidebars Go in to your functions.php file. You should see some sidebars already being registered. The code will look something like this: //Adds default sidebar if ( function_exists(‘register_sidebar’) ) register_sidebar(); To … Read more