Help with a single-page layout and including Advanced Custom Fields!
-
Hello!
I’m trying to build a site with a few features:– About half a dozen pages, each with its own unique template.
– I’d like all the pages to appear on a single continuous index page.
– I’m trying to use Advanced Custom Fields for a large majority of the content.With the following code, I’m able to add at least the content from all six pages to a the index page with some basic formatting:
$pages = get_pages(); foreach ($pages as $page_data) { $content = apply_filters('the_content', $page_data->post_content); $title = $page_data->post_title; $slug = $page_data->post_name; echo "<div class='$slug'>"; echo "<h2>$title</h2>"; echo $content; echo "</div>"; }
But there are two problems with the fact that only the_content is being returned, and those are:
1. The ACF fields aren’t part of the content, so they don’t get returned.
2. The templates aren’t part of the content, so they don’t get returned.How do I get it to return the entire page as applied to its custom template and include the ACFs? Losing my mind a little bit over this!
Thank you so much in advance!
- The topic ‘Help with a single-page layout and including Advanced Custom Fields!’ is closed to new replies.