Conflict with custom WP_Query in header.php
-
I have a custom WP_Query outside the main loop, in my header.php, and also another one in footer.php. On my Forums List page (the top/base level of bbPress that lists all my Forums), the custom WP_Query in both header.php and footer.php, no longer works. It shows another instance of the bbPress Forums List, instead of showing the correct content (as it does on every other page of my site, including all other bbPress pages). My custom WP_Query is
$args = array(
'post_type' => 'page',
'page_id' => 218
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();the_content();
endwhile;
wp_reset_postdata();I also tried get_page, which also didn’t work.
$page_id = 218;
$page_data = get_page( $page_id );
$page_content = apply_filters('the_content', $page_data->post_content);
echo $page_content;I tried using a bbPress ShortCode in a WP-Page called “Forums”, and then also without a page, just using bbPress Permalink “Forums”, without a wp-page and shortcode. Same problem either way.
Why would bbPress conflict with these core WP functions? And why would it happen ONLY on the Forums List page? I also tested this in TwentyEleven, and the problem is there too.
- You must be logged in to reply to this topic.