Filter widget outputs

I’ve been trying to find a good solution for my problem, but I can’t seem to find anything on this topic at all.

I’ve got a custom sidebar, created by using register_sidebar and I’ve used wordpress’s widget customiser to drop in a search bar, categories, and archive of posts to this custom widget sidebar. This sidebar is then applied it to my template by calling dynamic_sidebar('my-sales-blog').

However, when it outputs the categories and archive, it is outputting ALL of the categories on my site, and an archive of ALL of my site’s posts! I’ve been trying to find a way to tell it to only output the categories and archives associated with my custom post type sales-blog.

Have any of you found any methods of filtering the widget output?

Solutions Collecting From Web of "Filter widget outputs"

The stock “category” widget uses wp_list_categories() and passes the arguments though widget_categories_args in the process.

716                 /**
717                  * Filter the arguments for the Categories widget.
718                  *
719                  * @since 2.8.0
720                  *
721                  * @param array $cat_args An array of Categories widget options.
722                  */
723                 wp_list_categories( apply_filters( 'widget_categories_args', $cat_args ) );

You should probably be able to push through the arguments you need.

The stock archives widget does essentially the same:

374                 /**
375                  * Filter the arguments for the Archives widget.
376                  *
377                  * @since 2.8.0
378                  *
379                  * @see wp_get_archives()
380                  *
381                  * @param array $args An array of Archives option arguments.
382                  */
383                 wp_get_archives( apply_filters( 'widget_archives_args', array(
384                         'type'            => 'monthly',
385                         'show_post_count' => $c
386                 ) ) );

So…

Have any of you found any methods of filtering the widget output?

Yes.

I would be tempted to create my own customized widgets though, rather than try to filter the Core ones.