0

I am using get_pages to get all the page content for my front page. I am passing post_content through the content filter

 $content = $page_data->post_content;
 $mycontent = apply_filters('the_content', $content);

If I don't do that, then widgets don't render properly and it causes other problems. One problem that this does cause is that it repeats the content of a single page. If I remove the filter, then the pages show as they should but widgets don't work on those pages anymore. I have my get_pages function set up in front-page.php and my settings set to have "home" as my front page and the blog page to show the posts page

 $pages = get_pages();
 foreach( $pages as $page_data){
    $content = $page_data->post_content;
    $mycontent = apply_filters('the_content', $content);  

    echo $mycontent;
  }

I tried using rewind_posts and wp_reset_postdata for the heck of it but it didn't work. Can anyone tell me why in this scenario, it would show the same page for each published page when passing it through the content filter?

  • You need to display full content from page that has set as a front page on front page, yes ? Do you need also a loop with posts, pages and custom posts on this page ? – Michael Jul 14 '18 at 5:13
  • Why don’t you use custom WP_Query and normal loop? – Krzysiek Dróżdż Jul 14 '18 at 6:22

Your Answer

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

Browse other questions tagged or ask your own question.