Support

Account

Home Forums Front-end Issues Customising a post

Helping

Customising a post

  • Hello,
    I’m not a developer so I’m a little in trouble in what I have to do:
    * I created all custom post fields and associated them to a specific category post called “Esercitazione”
    Then:
    * I need not only the answers, but also the labels to be displayed in frontend posts, without affecting the template of the posts associated to other categories
    Is there a way to solve it?
    I tried several instructions, but still I can’t figure out how.
    Thank you in advance for your patience
    D

  • Part of this is outside of ACF and that’s having a template for a post in a specific category. For this you should take a look at https://codex.wordpress.org/Function_Reference/wp_get_post_categories and https://codex.wordpress.org/Function_Reference/get_template_part. Basically you need to see what category your post is in and then either get a standard content template or a separate content template based on that.

    I would probably use a custom post type instead, https://codex.wordpress.org/Post_Types

    As far as showing the label and the value of a field, this is the basics

    
    $value = get_field('field_name');
    $field = get_field_object('field_name');
    echo $field['label'],': ',$value;
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Customising a post’ is closed to new replies.