• Hello
    I created custom fields in the ACF plugin and want to display them in a single post. I want to insert the code to display the fields in the child theme. I understand I need a file content-helpers.php?

    Where in the child theme do you need to upload this file? Which folder? What should be the folder hierarchy?

    /blocksy-child/template-parts/
    /blocksy-child/template-parts/inc/single/
    /blocksy-child/inc/single

    How right?
    thank

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author Creative Themes

    (@creativethemeshq)

    Hi!

    Please check this example: https://wordpress.org/support/topic/custom-post-template-16/#post-13105316
    It shows how you can override the single.php template. Only thing is, you need to override single-movie from the code snippet with single, since you want to change regular posts not custom post types.

    Please let me know if you still have any problems with this, I’ll be happy to help.

    Best,
    Andrei.

    Thread Starter Mykola Pekarskyi

    (@dizer7)

    Thanks for the answer!

    But, how to insert custom fields ACF inside this function blocksy_single_content(); ???

    I took the code from the file /blocksy/inc/single/content-helpers.php and inserted it into the file /blocksy-child/template-parts/single.php, then added custom fields. Data from the custom fields is not displayed.

    Checked the plugin “Post Meta Inspector” for the presence of fields and content – everything is ok.

    Theme Author Creative Themes

    (@creativethemeshq)

    @dizer7 Two options here:

    1. Override the whole blocksy_single_content() function from your child theme, since it is declared with function_exists(), this is possible.
    2. Let me know where exactly (a place in HTML or line of code in PHP) you need to put your ACF fields and give me your code snippet that you use and I’ll prepare an action in the theme for you to hook into. I’ll also prepare a code snippet for you with this new action.

    I’d recommend #2.

    Also, #1 option is bad in a lot of ways — you’ll copy a big chunk of code in your child theme and this can cause issues as new updates from us come in. Effectively, you’ll be responsible for maintaining this part of the code. That’s why I recommend going with the #2 option.

    Waiting for your reply.

    Best,
    Andrei.

    Thread Starter Mykola Pekarskyi

    (@dizer7)

    Here is the file content-helpers.php with my custom fields:
    https://pastebin.com/hwZ1m1Z4

    I am ready to use all methods, if only the fields work. The first method isn’t bad either. I will compare your code and make the necessary edits to my modified file.

    Thank you so much for your desire to help and advise! Your theme is awesome! I’m switching to it after a paid premium theme.

    Theme Author Creative Themes

    (@creativethemeshq)

    @dizer7 you can try to place this using this action blocksy:hero:after. That is, this code will look like this: https://gist.github.com/andreiglingeanu/a6c0401d5581bbf256839046ee499599

    And no overrides, PROFIT!

    Thanks for the words and please let me know if this method works better for you.

    Best,
    Andrei.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Child Theme + Custom Fields’ is closed to new replies.