Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Last active October 20, 2023 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finalwebsites/8901926f016dc5b0c3f7e97ab0538e50 to your computer and use it in GitHub Desktop.
Save finalwebsites/8901926f016dc5b0c3f7e97ab0538e50 to your computer and use it in GitHub Desktop.
Add aan extra description to your WooCommerce product archive with ACF
<?php
/*
Place this code in your functions.php file to show a short description before the grid on product categorie archive pages.
Disclaimer: Use this code snippet with extreme care and at your own risk.
*/
add_action('woocommerce_archive_description', function() {
if (!is_paged() && is_product_category()) {
if (function_exists('get_field')) {
$term_id = get_queried_object()->term_id;
echo '
<div class="more-category-info">
'.get_field('introtekst', 'product_cat_'.$term_id).'
</div>'; // change the first attribute to match your own field name
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment