#2471 closed defect (bug) (fixed)
bbp_exclude_forum_ids function bugging custom WP_Query
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.6 | Priority: | high |
Severity: | normal | Version: | 2.4.1 |
Component: | Component - Forums | Keywords: | needs-testing needs-patch |
Cc: | nashwan.doaqan@… |
Description
How to re-produce:
1) Create 1 normal forum and 1 private forum
2) Open a topic in normal forum and post a reply
3) Create a custom function that using a WP_Query in reply content.
You will see bbPress adds extra meta_query in your WP_Query and basically its corrupting your query for everyone except keymasters like this:
[meta_query] => WP_Meta_Query Object ( [queries] => Array ( [0] => Array ( [key] => _bbp_forum_id [value] => 1031 [type] => numeric [compare] => != ) ) [relation] => AND )
Is this working as intended? If it is, can you give me a solution for this?
Change History (8)
#2
@
10 years ago
Can you include an example of the new WP_Query you're calling in your custom function?
#3
@
10 years ago
My query is:
new WP_Query(array( 'post_type' => apply_filters( 'firmasite_pre_get_posts_ekle', array( 'post', 'page' )), 'post__in' => $posts, 'posts_per_page' => -1, 'ignore_sticky_posts' => 1, 'orderby' => 'post__in', ));
Its a part of function that helps users to link other contents in replies or topic like this:
http://theme.firmasite.com/support/topic/im-lost/page/2/#post-1443
(Btw, I can send you my theme so you can test it if you want. You can easily add content blocks to topics, replies in bbpress like this: http://base.theme.firmasite.com/forums/topic/example-topic/ )
#4
@
10 years ago
- Component changed from General to Forums
- Keywords needs-testing needs-patch added
- Milestone changed from Awaiting Review to 2.5
Thanks. I'll take a look in the next few days.
Moving to 2.5 to investigate.
#5
@
10 years ago
- Milestone changed from 2.5 to 2.6
I'm not able to duplicate this on the latest trunk.
Moving this to 2.6 so we can investigate after 2.5 is released.
#6
@
10 years ago
@JJJ,
I found it. Here try this:
1) Create 1 private forum
2) Add this code to functions.php or in a plugin/mu-plugin:
add_action('after_setup_theme', "firmasite_example_query" ); function firmasite_example_query() { $testing = new WP_Query( array( 'post_type' => array( 'post', 'page', 'topic' ), 'showposts' => 9, 'ignore_sticky_posts' => 1 )); print_r($testing); }
3) Check your site's any page, you will see print of query which have this excluding for everyone except keymasters:
[meta_query] => Array ( [0] => Array ( [key] => _bbp_forum_id [value] => 1701 [type] => numeric [compare] => != ) )
#8
@
10 years ago
- Owner set to johnjamesjacoby
- Resolution set to fixed
- Status changed from new to closed
my temporary solution is:
wp_query run