Home>Support>Use a page as part of a custom post template file

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. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 5 years, 6 months ago Alex S
    Hi, I Work Here

    Hi 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 );
    }
    
  2. 5 years, 6 months ago wenkunst

    Perfect! That’s what I was looking for :)

  3. 5 years, 6 months ago Alex S
    Hi, I Work Here

    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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More