Home Forums General Issues Get custom field value on category.php


Get custom field value on category.php

  • I have attached some ACFs to the categories of a custom post type. Now I need to fetch the data from those fields, but am unable to do so. I have also tried the method suggested on but not working.
    The code I am using is:

    <?php get_header(); ?>
    	$category_name = single_cat_title('', false);
    	$queried_object = get_queried_object();
    	$taxonomy = $queried_object->taxonomy;
    	$term_id = $queried_object->term_id;
            // Get field value
    	the_field('field_name', $taxonomy.'_'.$term_id);
    <?php get_footer(); ?>

    I am creating a custom template for categories.php and need custom data to be displayed on the category page.

Viewing 1 post (of 1 total)

The topic ‘Get custom field value on category.php’ is closed to new replies.