I’m creating a theme for WordPress. On the Posts Page I would like there to be opening content, and I would like to style this content with Page Builder.
In the past, what I’ve done is re-enable the posts editor for the Posts Page with the following code:
function editor_on_posts_page( $post ) { if ( $post->ID != get_option( 'page_for_posts' ) ) { return; } remove_action( 'edit_form_after_title', '_wp_posts_page_notice' ); add_post_type_support( 'page', 'editor' ); } add_action( 'edit_form_after_title', 'editor_on_posts_page', 0 );
Afterwards, I can add the content by implementing the following:
blog_page = get_post( get_option( 'page_for_posts' ) ); if ( $blog_page->post_content ) { setup_postdata( $blog_page ); the_content(); wp_reset_postdata( $blog_page ); }
The post outputs as expected. However, when the page is built using Page Builder the content outputs but the styling used within Page Builder is not.
After further investigation it appears that several items are not being included onto the page, including external style sheets, embedded style sheets, body tag classes, and javascript. The entire panel-layout html is being included, though unstyled.
What steps are required for me to have these key aspects work. It should be noted that the account I’m working with does have “SiteOrigin Premium” so I am able to implement any steps specific to this plugin.
Hi Jchute,
I’m not too sure why this is happening, but I suspect it may be due to how you’re fetching the post. I would personally recommend directly outputting SiteOrigin Page Builder in this situation. This would look something like this:
Alternatively, the following should also work:
The above PHP will check if SiteOrigin Page Builder is activated and if it is, check if the post has SiteOrigin Page Builder enabled. If it does, it’ll output it. If it doesn’t, it’ll run the_content();
By the way, as you’re a premium user, you’re entitled to priority email support. If you would like to make use of that, please follow the instructions found on your Page: Dashboard (please refer to the support tab). Please reference this thread and include your SiteOrigin Premium License in your email.
Thank you, Alex! Your first code worked perfectly.
I believe you had one minor mistake, where on the fourth line the content should be echo’d after being filtered, but the rest worked exactly as it needed to! Thanks for all the help!
Also, the blogs I’m working on have SiteOrigin Premium, however, our lead has purchased the package and I do not have access to that account. Thanks for your help anyway!
Hi Jchute,
Great to hear! :)
Oh! Sorry, yes, you’re right – that line does need an echo.