Home > Blockchain >  Echo ACF oEmbed field in custom tab
Echo ACF oEmbed field in custom tab

Time:11-01

I have added a custom tab to WooCommerce single product page, and I am trying to echo the ACF standard output to display an oEmbed video.

The tab is added successfully, but I'm struggling with the function adding content to the tab.

syntax error, unexpected 'virtual_video_tour' (T_STRING), expecting ';' or ','

I have also tried the process of 'RETURN' then 'ECHO' but still failed.

Could you please point me in the direction of where and what I'm doing wrong?

Thank you.

add_filter( 'woocommerce_product_tabs', 'woo_virtual_tour_tab' );
function woo_virtual_tour_tab( $tabs ) {
    $tabs['virtualtour_tab'] = array(
        'title'     => __( 'Video Tour', 'woocommerce' ),
        'priority'  => 50,
        'callback'  => 'woo_virtual_tour_tab_content'
    );
    return $tabs;
}

function woo_virtual_tour_tab_content () {
echo '<div >
        <?php the_field('virtual_video_tour'); ?>
        </div>';
}

CodePudding user response:

Your <?php is open...

In other words, you didn't close the echo statement before you output the field, or tried to use <?php again.

function woo_virtual_tour_tab_content () {
    echo '<div >';
        the_field('virtual_video_tour');
    echo '</div>';
}

Or you can use concatenation like this:

function woo_virtual_tour_tab_content () {
    echo '<div >'. the_field('virtual_video_tour'). '</div>';
}
  • Related