I have 3 pages under the same custom post type that I made, and I made a custom field of choose between 3 answers when posting a new post to this custom post type and make it so that each page has the same template but shows the posts according to the custom field I made with ACF.

is there a way to do it without making 3 different templates? the 3 pages are supposed to look the same just the posts are different according to the ACF that I choose. thanks.

  • 1
    Yes, there are ways to do it. – Max Yudin Feb 8 '18 at 10:13
  • You should refer to the ACF documentation for how to use the field values in templates. – Jacob Peattie Feb 8 '18 at 11:05
  • I know how to show the posts according to the ACF but I couldn't find how to use the same template for it – Asaf Hadad Feb 8 '18 at 11:08

Yes, the WordPress template hierarchy provide a range of templates files to use.

In this case, you should look at the single-$post-type.php file. $post-type being your custom post type slug.

Include your template code, including ACF get_field calls, and the pages will look the same, but use the content from each post.

| improve this answer | |
  • That wasn't the question. They were asking about showing something different based on an ACF field. – Jacob Peattie Feb 8 '18 at 11:05

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.