So I have a Custom Post Type called Homepage. Homepage are separate posts that get queried on the home page. I have a beaver builder post that loses its layout on the home page. But if you look at that page as a single post (not on the homepage) the layout is in tact. What appears to be happening is in the wp query on the homepage, the beaver builder modified page it’s lost its markup, whereas on the single post view the markup is intact.
This is a new install, so this hasn’t worked yet in the way I intend it. Thoughts there?
For reference here’s what I have for the homepage query
<?php
// WP_Query arguments
$args = array (
'post_type' => array( 'homepage' ),
'post_status' => array( 'publish' ),
'orderby' => 'menu_order',
'order' => 'DESC',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
get_template_part( 'page-templates/content', 'home' );
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
And for the actual post loop
<?php
/**
* The template for displaying the homepage.
*
* This page template will display any functions hooked into the <code>homepage</code> action.
* By default this includes a variety of product displays and the page content itself. To change the order or toggle these components
* use the Homepage Control plugin.
* https://wordpress.org/plugins/homepage-control/
*
* @package storefront
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php echo the_content(); ?>
</article><!-- #post-## -->
Thanks for the detailed info. The reason this is happening is because Beaver Builder only loads its CSS/JS assets for posts in the main query. It’s not possible for us to enqueue assets for posts in secondary queries (especially ones run after wp_head).
In order to get the assets for those posts to load, you’ll need to use the fl_builder_global_posts filter found here…
and drop it into functions.php, my assumption is that any post with a post id of ‘123’ that is called in a custom wp_query function or in a sidebar—or anywhere else—will retain it’s beaver builder css, js and markup? Do I have that right? It’s just a matter of getting the right post IDs.
My apologies for the delay. The reason your code isn’t working is because you are loading all of the post objects into the $post_ids variable. Instead, that needs to be an array of post IDs like this…