Home › Forums › General Issues › Custom field on category pages? › Reply To: Custom field on category pages?
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:
<?php
$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:
</div>
<?php
$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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.