Home > other >  Wordpress Custom Fields in own Single Page
Wordpress Custom Fields in own Single Page

Time:09-08

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?

CodePudding user response:

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

CodePudding user response:

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"]

CodePudding user response:

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.

  • Related