WordPress filter hook · part of WordPress core

widget_posts_args

A WordPress core filter that 38 plugins also fire themselves, running on 13K+ sites between them.

“Filter the arguments for the Recent Posts widget.”

How to use widget_posts_args

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'widget_posts_args', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from xili-language's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

38 plugins that fire widget_posts_args

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WCFM Marketplace icon WCFM Marketplace10,000+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'author' => $store_id ), $instance ) includes/store-widgets/class-wcfmmp-widget-store-recent-articles.php:68
  2. xili-language icon xili-language600+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) xili-includes/xili-language-widgets.php:144
  3. ACF Recent Posts Widget icon ACF Recent Posts Widget500+ installs apply_filters( 'widget_posts_args', $query_args ) classes/acf-widget-widget.php:147
  4. core plugin for kitestudio themes icon core plugin for kitestudio themes300+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ) ) includes/widgets/widget-recent-posts.php:18
  5. Recent Posts Widget Advanced icon Recent Posts Widget Advanced300+ installs apply_filters( 'widget_posts_args', $query, $instance ) includes/query.php:87
  6. Administrator Z icon Administrator Z200+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'post_type' => $post_type, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ), $instance ) src/Widget/Adminz_RecentPosts.php:30
  7. Recent Post Widget Thumbnail icon Recent Post Widget Thumbnail100+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) widgets/recent-post-core.php:56
  8. OnionBuzz icon OnionBuzz100+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post_type' => $post_type ) ) lib/Widgets/WP_Onionbuzz_Recent_Posts.php:74
  9. Featured Posts Pro icon Featured Posts Pro100+ installs apply_filters( 'widget_posts_args', $postArgs ) includes/class-featured_posts_pro.php:311
  10. Pro Recent Post Widget icon Pro Recent Post Widget100+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true,'cat'=>$post_category,'post__not_in'=>$exclude_post ) ) pro-recent-post-widget.php:40
  11. Listings Post Type Enable icon Listings Post Type Enable100+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number,'post_type'=>'listing', 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) listings.php:170
  12. Minimalistic Event Manager icon Minimalistic Event Manager60+ installs apply_filters( 'widget_posts_args', array( 'post_type' => $post_types, 'posts_per_page' => -1, 'meta_key' => '_mem_start_date', 'meta_value' => $mem_180day_iso, 'meta_compare' => '>=', 'orderby' => 'meta_value', 'order' => 'DESC', 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ) ) widgets/event-list.php:187
  13. Custom Content icon Custom Content60+ installs apply_filters( 'widget_posts_args', array( 'post_type' => 'custom-content', 'post__in' => array($instance['showescontents']), ) ) inc/custom-content-widget.php:28
  14. Epic Tap Widgets icon Epic Tap Widgets20+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) includes/widgets/widget-recent-post.php:55
  15. IG Portfolio icon IG Portfolio20+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'post_type' => 'project', ) ) extra/ig-portfolio-project-widget.php:23
  16. Sogo Calendar Widget icon Sogo Calendar Widget20+ installs apply_filters( 'widget_posts_args', array( 'post_type' => $post_type, 'posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => $meta_filed, 'value' => array($month_start, $month_end), 'compare' => 'between' ) ) ) ) plugin.php:253
  17. RSVPMaker for Toastmasters icon RSVPMaker for Toastmasters10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'category_name' => 'members-only', 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ) ) core.php:16058
  18. List of User’s Posts Widget icon List of User’s Posts Widget10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'author' =>$current_user->ID ) ) louposts.php:94
  19. Custom News Widget icon Custom News Widget10+ installs apply_filters( 'widget_posts_args', array( 'post_type' => 'news', 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ), $instance ) includes/class-cnw-widget.php:58
  20. Blesk Companion icon Blesk Companion10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) widgets/latest_news.php:70
  21. JS Widgets icon JS Widgets10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $instance['number'], 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'update_post_meta_cache' => false, 'update_term_meta_cache' => false, ) ) core-adapter-widgets/recent-posts/class.php:82
  22. Members Only Posts icon Members Only Posts10+ installs apply_filters( 'widget_posts_args', $qargs ) members-only.php:114
  23. Forethemes Functions icon Forethemes Functions10+ installs apply_filters( 'widget_posts_args', $get_post_args ) widgets/forethemes-custom-post-widget.php:83
  24. Pro Related Post Widget icon Pro Related Post Widget10+ installs apply_filters( 'widget_posts_args', $arg ) pro-related-post-widget.php:57
  25. HTML Classified Recent Posts & Comments Widgets icon HTML Classified Recent Posts & Comments Widgets10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) html-classified-recent-post-comments-widgets.php:55
  26. Switch Last Posts Widget icon Switch Last Posts Widget10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'cat' => $categorieToUse ) ) switch-last-posts-widget.php:124
  27. Gallery Recent Posts icon Gallery Recent Posts10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number_posts_pic, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'meta_query' => array( array( 'key' => '_thumbnail_id' ) ) ) ) gallery_recent_posts.php:66
  28. WP Immo icon WP Immo10+ installs apply_filters( 'widget_posts_args', $args_query ) includes/wpimmo-widgets.php:72
  29. User Photo icon User Photo10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) widget-latestarticles.php:30
  30. WP All Post Type Widget icon WP All Post Type Widget10+ installs apply_filters( 'widget_posts_args', $post_args ) classes/class-widget.php:58
  31. Manage Issue Based Magazine (Multi-language) icon Manage Issue Based Magazine (Multi-language)10+ installs apply_filters( 'widget_posts_args', $featured_artcile_args ) mim-widgets.php:854
  32. SOGO Author’s Recent Posts icon SOGO Author’s Recent Posts10+ installs apply_filters( 'widget_posts_args', array( 'post_type'=> $post_type, 'posts_per_page' => $number, 'author' => $user->ID, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) plugin.php:95
  33. GA-PVcounter icon GA-PVcounter10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => GA_PVC_RECENTPOSTS, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) GA-PVwidget.php:315
  34. Stick Post Widget icon Stick Post Widget10+ installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => false,'post__in' =>$sticky_posts) ) stick-post-widget.php:43
  35. Lenxel AI LMS icon Lenxel AI LMSFewer than 10 installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, ), $instance ) widgets/recent_posts.php:68
  36. Share Theme Plugin icon Share Theme PluginFewer than 10 installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) widgets/share-theme-plugin-recent-post-widget.php:40
  37. WP News Photo Gallery icon WP News Photo GalleryFewer than 10 installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'post_type' => array('wpnpg', 'ignore_sticky_posts' => true ) ) ) lib/widget.php:50
  38. Lingenio Translation Service icon Lingenio Translation ServiceFewer than 10 installs apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) pg_widgets/default_widgets_new.php:44

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.