Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1302625
    hjaffer
    Participant

    Hi

    I’m trying to echo an ACF within a shortcode but It’s driving me crazy. Here’s what I’m trying to achieve.

    <?php 
    if ( get_field( 'app_size' ) < 100 ) {
    echo "<?php the_field( 'app_size' ); ?> MB";
    } else {
    echo do_shortcode( '[extra href="#" title="Beware!" info="popover" info_place="top" info_trigger="hover" info_content="CONTENT HERE" ]<?php the_field( 'app_size' ); ?> MB[/extra]' );
    } 
    ?>

    The statement works, only thing is I can’t figure out how to add the ACF in the shortcode in the second part of it (the shortcode).

    Any chance you could help here?

    Thanks

    #1302632
    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! You can simply use this code:

    <?php 
    if ( get_field( 'app_size' ) < 100 ) {
      echo "<?php the_field( 'app_size' ); ?> MB";
    } else {
      $shortcode = '[extra href="#" title="Beware!" info="popover" info_place="top" info_trigger="hover" info_content="CONTENT HERE" ]' . the_field( 'app_size' ) . ' MB[/extra]';
      echo do_shortcode( $shortcode );
    } 
    ?>

    We would loved to know if this has work for you. Thank you.

  • <script> jQuery(function($){ $("#no-reply-1302625 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>