[wp-trac] [WordPress Trac] #35603: Allow `wp_count_posts()` on multisite after switching sites
WordPress Trac
noreply at wordpress.org
Mon Jan 25 14:48:49 UTC 2016
#35603: Allow `wp_count_posts()` on multisite after switching sites
-------------------------------+-----------------------------
Reporter: flixos90 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Keywords:
Focuses: multisite |
-------------------------------+-----------------------------
When switching sites on a multisite, there can be problems when using
`wp_count_posts()`:
Let's say you are on site X and site Y has a post type 'event' registered
while site X does not have it. When you switch from X to Y using
`switch_to_blog()` and then call `wp_count_posts( 'event' )`, there won't
be any results since this post type does not exist on site X and since
it's not possible to register post types per sites when switching between
sites.
I think we should only make the `post_type_exists()` control call when we
can ensure that we've not switched sites. The function will still work
properly without it. And since we can still correcly `get_posts()` of such
a post type after switching sites, we should be able to also use
`wp_count_posts()` correctly.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35603>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list