PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 18, 2022

[FIXED] Echo ACF oEmbed field in custom tab

 January 18, 2022     advanced-custom-fields, php, woocommerce, wordpress     No comments   

Issue

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 class="embed-container">
        <?php the_field('virtual_video_tour'); ?>
        </div>';
}

Solution

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 class="embed-container">';
        the_field('virtual_video_tour');
    echo '</div>';
}

Or you can use concatenation like this:

function woo_virtual_tour_tab_content () {
    echo '<div class="embed-container">'. the_field('virtual_video_tour'). '</div>';
}


Answered By - Howard E
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing