Support

Account

Home Forums General Issues ACF in attachment-single.php Reply To: ACF in attachment-single.php

  • 1) what are you puting in the chapo field.
    <p>WYSIWYG content from get field</p>

    2) what are you putting in the content editor
    <audio><!-- attachment audio stuff... --></audio>
    (this really is the media file)

    3) where / how is the attachment being added
    From the media library (wp-admin/media-new.php)

    4) whats the code in your php file
    page.php

    <?php
    get_header();
    
    while (have_posts())
    {
      the_post();
    
      if ( get_post_type() == 'attachment' )
      {
        get_template_part( 'attachment', 'single' );
      }
      else
      {
        get_template_part( 'content', 'page' );
      }
    }
    
    get_footer();

    attachment-single.php

    <div class="chapo">
      <?php
      if ( get_field( 'chapo' ) )
      { ?>
        <?php echo get_field( 'chapo' ); ?>
      <?php
      } ?>
    </div>
    <div class="content">
      <?php the_content(); ?>
    </div>

    5) what should be the desired output?

    <div class="chapo"><p>WYSIWYG content from get field</p></div>
    <div class="content"><audio><!-- attachment audio stuff... --></audio></div>

    6. What actually appears?

    <div class="chapo"><audio><!-- attachment audio stuff... --></audio><p>WYSIWYG content from get field</p></div>
    <div class="content"><audio><!-- attachment audio stuff... --></audio></div>

    Note: This happens with any media file, not just audio.