I am trying to display the contents of an arbitrary field (Advanced custom fields) in a single record template. I do this: <? Php get_header (); ?>
<!-- begin content --> <div class="content"> <div class="content-page"> <?php the_post(); ?> <div class="content-main"> <h1 class="page-title"><?php the_title(); ?></h1> <?php the_content(); ?> <?php the_field('code'); ?> //ВЫВОД СОДЕРЖИМОГО ПРОИЗВОЛЬНОГО ПОЛЯ </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
As a result, content is displayed, but for some reason AFTER a block of comments.
Found a way to display content like this:
add_filter('the_content', 'add_text_to_content'); function add_text_to_content($content){ $out = $content . "тест"; return $out; }
Displays a "test", before comments, as it should. How to substitute the value of an arbitrary field instead of text?
Did so:
add_filter('the_content', 'add_text_to_content'); function add_text_to_content($content){ $mycode = the_field('code'); $out = $content . $mycode; return $out; }
Displays content, BUT - at the very beginning of the post!