It makes no difference whether I use the_field
or get_field
. I have tried both.
I have no problem displaying the content. Please do not concern yourself with the_content
.
The problem is that what is returned from get_field
(or displayed by the_field
) __includes__ the content.
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.
No, I’m sorry if I was unclear. The problem is that the *content* of the post is being displayed where **get_field** is called. For example, on attachment pages, the attachment content appears before the content of the field:
<audio><!-- attachment audio stuff... --></audio>
<p>WYSIWYG content from get field</p>
The entire **<audio/>** tag should not appear there, it is not called in the code and is not in the WYSIWYG content of the field.
This error only appears with WYSIWYG fields.
The screen only shows the type of field that I use.
The code I use is as follows:
<?php
if ( get_field( ‘chapo’ ) )
{ ?>
<?php echo get_field( ‘chapo’ ); ?>
<?php
} ?>
<?php the_content(); ?>
In get_field(‘Chapo’) is being added what is on the_content(); and the content of get_field(‘Chapo’).
The same goes for other get_field I have on the page.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.