• Resolved rygramer

    (@rygramer)


    Hi!

    I am trying to activate a single image in an Advanced Custom Field (ACF) WYSIWYG Editor. Here’s the progess I’ve made:

    
    <?php if(get_field('faq')): ?>
     <?php while(has_sub_field('faq')): ?>
      <h3><?php the_sub_field('question');?></h3>
      <?php 
       $content = the_sub_field('answer');
       if ( function_exists('slb_activate') )
        $content = slb_activate($content);
        echo $content;
      ?>
     <?php endwhile; ?>
    <?php endif; ?>
    

    What am I doing wrong? Thanks for your help!

    • This topic was modified 4 years, 9 months ago by rygramer.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Archetyped

    (@archetyped)

    Hi, ACF’s the_sub_field() template tag directly outputs the content to the browser (just like WordPress’ own the_content(), etc. template tags), so nothing is being saved to the $content variable.

    Documentation: ACF | the_sub_field()

    To save a sub-field’s contents to a variable, you have to use get_sub_field().

    Documentation: ACF | get_sub_field().

    Please post an updated link if you are still experiencing this issue after updating your code and I would be glad to reopen this ticket and take another look.

    Thanks.

    Thread Starter rygramer

    (@rygramer)

    Thank you so much! That solved it ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Advanced Custom Field (ACF) Single Image in WYSIWYG Editor’ is closed to new replies.