【发布时间】:2015-10-09 18:46:02
【问题描述】:
我使用名为“colaboradores”的高级自定义字段插件创建了一个自定义字段,其中包含字段徽标(图像)、方向(字符串)和地图(图像);
在 archive-colaboradores.php 中,我调用了 WP_Quer。简而言之,代码是:
<?php
$args = array(
'post_type' => 'colaboradores',
'pagination' => false
); ?>
<?php $the_query = new WP_Query( $args ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'colaboradores' ); ?>
<?php endwhile; // end of the loop. ?>
所以在 content-colaboradores.php 中,我使用 the_field() 显示我的自定义字段:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php $image = get_field( 'logo' ); ?>
<?php echo '<img src="' . $image['url'] . '" >'; ?>
<?php echo '<p>' . the_field('direccion') . '</p>'; ?>
<?php $image = get_field( 'mapa' ); ?>
<?php echo '<img src="' . $image['url'] . '" >'; ?>
</article><!-- #post-## -->
一切都很好,除了方向,它总是在 标记之外用谷歌浏览器检查:
我已经删除了 ' 之前的所有代码。 the_field('方向') 。 '
'; ?> 但问题仍然存在。你知道为什么会这样吗?谢谢。
【问题讨论】:
-
感谢您的回答!我
ve found the problem: *the_field()* includes the echo: [ACF - the_field](http://www.advancedcustomfields.com/resources/the_field/)[/link], final code which works is:`