Home Forums General Issues Custom field on category pages?


Custom field on category pages?

  • Hi,

    I’m using WooCommerce to build a webshop on WordPress.

    WooCommerce comes with a custom taxonomy called “product_cat”. This is the category pages, see eg.

    I would like to ask if it is possible to add a rich text field to these category pages via the Advanced Custom Fields plugin?

    As far as I can see, the custom fields only seems to be applicable on ordinary posts and pages – not category pages.

    Hope you can help 🙂 Thx!

  • Hi @psejersen

    ACF can be added to a taxonomy term edit page. Just select the location rule of ‘Taxonomy term’ nad then select which taxonomy you wish for the field group to show on (product_cat).

    Next, you will need to read this article to load the data into your template:


  • Excellent, it works. I guess I couldn’t figure it out because the rule field was just called “Term” and not something like “Taxonomy term”.

    Thanks for the help, I look forward to using it to making the site even more awesome 🙂

  • Hi @psejersen

    Thanks for the feedback, good point!

  • Hi
    i do something wrong. The first part already works, but i can’t display the value. I want to create a new “SEO text field” and added an wysiwyg-field, which show up at every category.


    <p><?php the_field('myafcfield', $term); ?></p>
    <p><?php the_field('myafcfield', $taxonomy); ?></p>

    dont show anything. I have the right template and cache is disabled.
    what i have todo ?


  • I’am not that good at coding, english & thinking ;), but try and error works.

    $queried_object = get_queried_object(); 
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;  
    the_field('youracffield', $taxonomy . '_' . $term_id);

    does it.

  • hi, how can I use ACF field-group only on 1 category ?
    I have category Books, and I there filds like “Author of book” , ” Original language” , and “Cover”. And all the books are categories too, with Parent “Book”.
    In other categories , except Books children, i don’t need this fields, but they shows.

    i set in Rules “Taxonomy therm = Categories” , but thery are’n any filter for Parent of category (like for posts )

  • @rustamaha – this might be a little late for you now, but you can select just one category by selecting Post Category, rather than Taxonomy Term.

    Selecting Categories

  • @waterlemon Thank you for sharing your thoughts and final solution!
    I have exactly the same issue (I want to display an unique SEO description below my product feed on every woocommerce category site) but unfortunately your solution did not succeed so far.

    Could you – or @ma4ine – please specify a little more what you did:
    The changes were made in the taxonomy-product_cat.php or in archive-product.php?

    I tried both (incl. replacing the field name, of course) but nothing happend…
    First, I copied the original files and uploaded the changed files then to yourtheme/woocommerce/… to overwrite the original files (/plugins/woocommerce/templates/…). Maybe that is not the right way to do it?

    Would be very thankful to get more information on that. Unfortunately I have very few experience on programming etc. and trying to get that done for many hours now, puh… 😉
    Would be awesome, thanx!!

  • Updated url for the solution that works for woocommerce and acf with product category


  • Hello,
    i’am sorry, didn’t saw the e-mails from this post.
    The code has changed – don’t know why anymore.
    But this worked for me:

    	$term_id = get_queried_object()->term_id;
    	$post_id = 'product_cat_'.$term_id;	 
    	$custom_field = get_field('ACFFIELD', $post_id); // My Advanced Custom Field Variable
    	<div id="seo-text"><?php echo $custom_field; ?> </div> <?php // Get Advanced Custom Field Value ?>

    You have to add it in the archive-product.php under the last div and below the footer.
    If you have a child-theme, you need to copy that php file to your child theme with the same template structure. Research how to overwrite template files in your child theme.

    Here again:

    	$term_id = get_queried_object()->term_id;
    	$post_id = 'product_cat_'.$term_id;
    	$custom_field = get_field('cat-seotext', $post_id); // My Advanced Custom Field Variable
    	<div id="Seo-text"><?php echo $custom_field; ?> </div> <?php // Get Advanced Custom Field Value ?>
    <?php get_footer(); ?>

    best luck

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘Custom field on category pages?’ is closed to new replies.