This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Row background image not showing when using $post->post_content

8 years ago · Last reply by Jeff Pedigo 8 years ago

I’m showing the content a page on an archive page. Here’s the code:

$page = get_page_by_path($post_type);

if ($page) {
	echo apply_filters('the_content', $page->post_content);
}

This allows me to create pages with the same slug as a custom post type so I can show that page’s content at the top of the archive page. Works just fine, but the background images do not appear to be showing. When looking at the generated html, I can still see the data-style attribute on the row container, so something’s not getting picked up. It’s on a private dev site right now, so I can’t share it, but I’ll try to get it posted on a public server if that’ll help.

Thanks!

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

3
  1. Jeff Pedigo 8 years, 4 months ago

    I solved this by using a wp_query to pull up the desired post, at which point just using the_content() worked to show all the Page Builder formatting. So, the working code is:

    $query = new WP_Query(array('post_type' => 'page', 'name' => $post_type));
    if ( $query->have_posts() ) {
    	while ( $query->have_posts() ) {
    		$query->the_post();
    		the_content();
    	}
    	wp_reset_postdata();
    }
  2. Alex S Staff 8 years, 4 months ago

    Hi Jeff,

    I would recommend using the following PHP:

    
    $post_id = get_the_ID();
    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 );
    }
    
  3. Jeff Pedigo 8 years, 4 months ago

    Thanks Alex S. Worked like a charm!

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.

Have a different question or issue?

Start New Thread