Use a page as part of a custom post template file
I have a custom post type (event) with a template file for showing single posts (single-event.php). That’s working fine.
I want to show some information on every single posts pages, build with the page builder, like a footer which is the same on every event page. I made a page called ‘footer’ and designed that with the Page Builder. When I insert that page in the template file with this code I don’t get the Page Builder styling:
$post = get_post($id);
$content = $post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;Is it possible to add a page in a template file like that? Or is there a better way to get this result?
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
3Hi Wenkunst,
We recommend rendering SiteOrigin Page Builder directly if you’re outputting SiteOrigin Page Builder outside of the loop. Here’s an example of the code I typically recommend to do this:
if ( class_exists( 'SiteOrigin_Panels' ) && get_post_meta( $post_id, 'panels_data', true ) ) { echo SiteOrigin_Panels::renderer()->render( $post_id ); } else { echo apply_filters( 'the_content', get_post( $post_id )->post_content ); }Perfect! That’s what I was looking for :)
Hi Wenkunst,
Great to hear that helped! :)
Please be sure to post another thread if you have any other questions.
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.