ncesar
ncesar

Reputation: 1802

ACF Text field not being rendered inside the right hierarchy

I have created 2 text fields using ACF and they work just fine. The problem is that i'm using Enfold Theme and everytime i put the ACF shortcode inside a column with a Code Block, the text field will not respect the hierarchy and it goes to the top.

This is what happens(The divs with "Esse texto é editável na página de opções" is the acf text field):

wrong hierarchy

The divs with the 6 text fields were supposed to be above this avia_codeblock

enter image description here

This is how i'm calling the ACF in functions.php as a shortcode:

function vComp(){
    echo '<div>';
    echo the_field( 'titulo_do_texto_1' );
    echo '</div>';

}
    add_shortcode( 'titulo1', 'vComp' );

And in the codeblock i just write [titulo1]. I really dont know what i'm supposed to do, can someone please help me? If needed, latest wp version, with Enfold Theme, and domain is https://template1.portifolium.com/sobre/

Many thanks in advance.

Upvotes: 0

Views: 234

Answers (1)

user8554313
user8554313

Reputation:

Please, consider to return your shortcode value instead of displaying

function vComp(){
    $shortcode_content = '<div>' . get_field( 'titulo_do_texto_1', get_the_ID() ) . '</div>'

    return $shortcode_content;
}

add_shortcode( 'titulo1', 'vComp' );

Upvotes: 1

Related Questions