• I have Some Custom fields associated with a CPT that I created using ACF Pro. To show them I use the default Astra child theme and copied single.php to my child theme as single-{cpt}.php

    My custom fields are showing on the page but not in the content area.

    So How do I show my custom fields in the content part just after the content title?

    And remove the Next and Previous CPT link from the footer area?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @tatai1985,

    Instead of copying the single.php to your child-theme, please use the following snippet to show the Custom Field you created using the ACF plugin

    add_action('astra_entry_content_before' , 'show_acf_field');
    function show_acf_field() {
    	echo "<p>" . the_field('field_name') . "</p>";
    }

    ?Please change the 'field_name' to your actual Custom Field name.

    ?And to remove the Next/Previous navigation of the CPT, you can use the snippet on this gist.
    ?
    ?I hope that will help. Feel free to reach out to us if you have any further queries.

    ??Kind regards,
    ?Herman ??

    Thread Starter Saptak

    (@tatai1985)

    Thanks but I also need this to make other custom queries. So can you tell me which is the temple file that need to be edited to show fields on the single.php ?
    And archive.php ?

    Hi @tatai1985,

    ?Sorry for the delay.
    ?
    You can override the single.php and archive.php using child-theme by adding the CPT slug, however, you will need hooks to show the Custom Fields inside the content area.
    ?
    ?I hope it helps. Feel free to reach out to us if you have any further queries.

    Kind regards,
    Herman ??

    P.S. We recommend reaching out to us through our Support Portal for faster and quicker help and resolution as mentioned here.

    I have this issue too. But I’m unfamiliar with hooks and where to put them so that only custom fields that I’ve created for the custom post type will only show up in that custom post type and no other.

    Screenshot of what I’d like to see.

    • This reply was modified 4 years, 5 months ago by GinaW.

    Hi @tacaha5,

    For the Astra Hooks, you can refer to this Visual Guide.????? Or you can install our Astra Theme Visual Hooks plugin to see all hook locations in the Astra theme.
    ?
    ?I hope it will help. Feel free to reach out to us if you have any further queries.

    ??Kind regards,
    ?Herman ??

    Thank you Herman for you help with this and leading me onto the right path. I appreciate your help.

    ??You’re welcome, it’s been a pleasure to help you, @tacaha5!
    ?
    ?Anyway, I notice that you have a topic with the same query which I also previously responded. Please mark it as resolved and do let us know if there’s anything else we can help you with.

    ??Have a nice day and stay safe!

    ??Kind regards,
    ?Herman ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Showing CPT ACF Fields on the Single post template’ is closed to new replies.