skip to Main Content

I am using the Advanced Custom Fields and a Custom Post Type.

Currently I am using a child theme from Block Theme 2022:
https://de.wordpress.org/themes/twentytwentytwo/

I am now trying to output the Custom Fields on the Single Page of the Custom Post Type as described here:
https://www.advancedcustomfields.com/resources/adding-fields-posts/

I have created my single-myCustomPostType.htm in the template folder, this is also used. However, I can not simply output my field here?

<?php the_field('mycustomfield'); ?>

If I then edit the template once in the WordPress-Editor, HTML-Template changes no longer appear. Only when I discard the editor changes, the changes from the template appear.

Is there perhaps a better approach to output the custom fields?

3

Answers


  1. Chosen as BEST ANSWER

    Unfortunately, I don't know how to write a shortcode for the details page. I have now manually inserted the fields into the singlepage template via the Gutenberg editor as follows [acf field="yourACFfieldName"]


  2. yes create shortcode and add in editor, to display you can use global $post to fetch data

    Login or Signup to reply.
  3. I have created my single-myCustomPostType.htm

    .htm???

    If it’s not a typo it’s the problem you’re looking for.

    Moreover single-myCustomPostType.PHP pages don’t go in the Template folder, they go in the theme folder.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search