Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1344970

    I need to have special fields for some categories in the posts and I am using ACF.

    What is the best way to do this and to which template I should add my custom fields code?

    A simple example with an if category1, category2, and is single can help to know where and how to add the code.

    Thanks.

    #1345006

    Hey peterolle,

    Thank you for the inquiry.

    Where are you displaying the custom fields? Did you modify a template to display them? You should probably add the conditional tags around those modifications. This documentation should help.

    // https://developer.wordpress.org/reference/functions/has_category/

    Example:

    if( has_category("dog"), get_the_ID() ) {
       // echo custom field
    }
    

    In the code above, the custom field will only display if the post has the category “dog”.

    Best regards,
    Ismael

    #1345057

    Where are you displaying the custom fields? Did you modify a template to display them?

    It will be for normal posts under certain categories.

    Not implemented yet. Which file should I modify to display them?

    Thanks.

    #1345316

    Hi,

    Thank you for the update.

    Which file should I modify to display them?

    You may need to modify the includes > loop-index.php file if you want the custom fields to display on the single post page.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.