Support

Account

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