The problem is that you’re not modifying the existing arguments for the widget, you’re replacing them:
add_filter('widget_posts_args', function() {
$params['post_type'] = array('post', 'recipe');
return $params;
});
The result of that filter will be:
$params = [
'post_type' => [ 'post', 'recipe' ]
];
So any other arguments, including the default number of posts, are removed.
This is because you’re not accepting the original value into your filter. Your callback function needs to accept this as an argument, so that you can modify and return it:
add_filter('widget_posts_args', function( $params ) {
$params['post_type'] = array('post', 'recipe');
return $params;
});
This is how filters work. You use a function that accepts the original value, and returns a new value.
Related Posts:
- Stored meta from attachment, video length?
- WordPress trying to query two custom types to get child from the parent
- tax_query not working?
- PHP Notice: Unidentified index
- How to get the posts that my following users are liked?
- How to mix 2 kinds of post types
- CPT: execute code after load if parameter is set
- Wrap each child and it’s grandchildren separately
- Add active class to foundation 6 tabs while looping categories
- Print post category name from a custom post type wordpress
- Create unordered list from custom field type entires separated by a comma
- CPT post doesnt shows tags and category on backend admin page
- Duplicate posts in my custom loop
- ACF Post Content Not Being Searched
- Include images from pages in wp search.php results in default wp search
- Display related post content and custom field content
- The most recent post of custom taxonomy
- Custom 404 redirect for a luddite
- How to make sure, that only the selected post is changing?
- Show tags of custom post types in WordPress
- WordPress loop add heading before first of type
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- WordPress query posts by custom post type not workng
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- WP_Query return highest number only
- Meta box not saving
- Show custom taxonomy not in submenu
- Getting a 404 on single custom post type page when using rewrite on a custom taxonomy
- Featured image in custom post is being disabled
- Can’t pick up a field created with Advanced Custom Fields
- Pods pagination erases my sub menu
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- can’t see categories in appearance-menu-categories
- Loop carousel slider in wordpress
- Meta Box not being added in plugin
- How to Fix WordPress 500 Internal server error due to custom post type
- Custom Post save causes 500 error
- Why is my custom post type slider only displaying the latest slide?
- Why isn’t my custom post type using the corresponding custom post template?
- Custom post tag images not displaying with ACF
- Get month and day from a Date Picker custom field
- wordpress form processing to custom post type not working
- WordPress custom field images not getting inserted into array
- Function not pulling image or text from custom post type
- Meta-Box to add multiple items one at a time and on publish save all
- Values inside a custom field to determine which category posts to display
- Custom Search not working
- Exclude Custom Post Type from shared Custom Taxonomy
- Show Custom Post Type taxonomy term that matches custom field
- WordPress Custom Post Type and sort by Tags
- using ACF datepicker to filter posts on a page
- How to call Shortcode categories for custom post types?
- Posts without featured image using other post’s featured image
- Order by custom field attribute
- WordPress multi-query not returning as expected
- Trying to combine multiple WordPress queries
- Return all wordpress custom posts in specific multidimensional array
- How to loose the image ‘alt’ attribute in my custom post type?
- Add number in increment of one to DIV ID
- Custom Post-type not returning the right child_of
- Select Menu for Custom post Type does not save
- shortcode for recent custom type post
- Looping taxonomy in taxonomy?
- Query recent posts by author
- Permalink of Custom Post Type
- Building a List of Posts grouped by custom taxonomy as the section header only to be displayed if at least one post is in that tax
- Adjust layout most recent post, taking pagination into account
- Custom Portfolio String
- posting twice from an array?
- Stop header code from showing in category page?
- is_singular won’t call my functions?
- Pagination not working on homepage
- Custom Loop for custom post type. Compare by meta_value?
- Query Custom Post Type by Tag
- What is the most efficient way to manage changes my product comparison tables?
- Dynamically change Custom Post Type Template OR Change Permalink?
- Cant we use a PHP file directly like myhome.com/some.php?
- Code in custom widget queries all posts, when it should only query the current post
- WordPress Set A Static Page/Template For All Sub-Pages
- Order custom post type is beign ignored
- Add HTML before a specific div?
- Inserting two categories
- How do I filter a custom post type loop by a field?
- How to hide home title on pages and posts?
- How to manage wordpress knowledge base/wiki/posts collections
- How to string lines from the_content() hook in WordPress?
- Get custom post fields and display them
- PHP Button Custom link [closed]
- Getting ACF relationship field information
- Comments are not working on Custom Post Type
- Is there any way of not using my_init_method in the following code (that creates a custom post type)?
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- Add Category names to post lists of custom post type
- How to dynamically register custom post type
- Store custom post type with JSON content
- How to I add count of custom posts listed in a post as a prefix to its title
- Custom post type is_singular condtional not working when managing sidebar display