-1

I have custom post type : edge, so I built some content by Visual composer. Now I need to display all post type edge in my page.

I use the following code in function to get posts but I can not keep the whole site structure by post_content.

   $args = array('posts_per_page' => -1,'post_type' => 'edge');
   $edge_array = get_posts( $args );
   foreach($edge_array as $e):
    echo $e->post_content; 
   endforeach;

it display the whole content but not styling like

[vc_row][vc_column width="1/2"][vc_column_text] product [/vc_column_text][/vc_column][vc_column width="1/2"][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]

I really want it to display exactly in the post with style, is it possible?

0

Try running the post content through the do_shortcode() function before displaying it.

$args = array('posts_per_page' => -1,'post_type' => 'edge');
$edge_array = get_posts( $args );
    foreach($edge_array as $e):
    echo do_shortcode($e->post_content); 
endforeach;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.