Support

Account

Home Forums General Issues Woocommerce+ACF return field value via functions.php

Solving

Woocommerce+ACF return field value via functions.php

  • Hi guys! I think you can help me with this issue. So, i need change Woocommerce category page title by ACF field value via functions.php. I have like this code:

    add_filter( 'woocommerce_page_title', 'custom_title' );
    function custom_title( $title ) {
        $title = '<?php the_field("h1_title", "product_cat_" . $product_cat_object->term_id); ?>';
        return $title;
    }

    But he show me “term_id); ?>” instead of title that entered in ACF field. How to make it work?

  • Hi @avegas

    Please change your code to:

    add_filter( 'woocommerce_page_title', 'custom_title' );
    function custom_title( $title ) {
        $title = get_field("h1_title", "product_cat_" . $product_cat_object->term_id);
        return $title;
    }
  • This method dont show anything… Instead of title a blank place

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

You must be logged in to reply to this topic.