CMB2 / cmb2-attached-posts

Custom field for CMB2 for attaching posts to a page.
GNU General Public License v2.0
135 stars 62 forks source link

Multiple post types issue #67

Closed c3po-developer closed 2 years ago

c3po-developer commented 2 years ago

Hi! Thanks for this great addon!

I'm experiencing a strange behavior.

I have configured the field with these arguments:

'query_args' => array (
'post_type' => ['post', 'tweets_sus', 'news_sus'],
),

And the posts of the type 'tweets_sus' do not appear. Only the posts of type 'post' and 'news_sus' appear.

If I modify it to leave it like this:

'query_args' => array (
'post_type' => ['tweets_sus'],
),

Then they appear.

The strangest thing is that if I make an independent query (With WP_Query() ) in any place of the same website with the 3 CPTs, all the results appear and i'm setting the exact same arguments to the module.

I have even modified the code from cmb2-attached-posts and I have reached the get_objects() function in init.php and I have verified that the arguments there, including the CPT 'tweets_sus' arrive correctly, but the get_posts() function returns only two CPT results. In the same function i try with WP_Query() and the results are wrong two.

This is the strangest thing, because i'm calling WP_Query() with same params outside the module and all works.

Any suggestion will be appreciated

c3po-developer commented 2 years ago

Sorry, my fault.

The problem comes from Polylang. All CPTs except _tweetssus had a defined language. What I don't quite understand is how it worked with the external WP Query ...

Hope this can be useful to someone in the future: P