2015-07-20 74 views
1

我创建了一个自定义字段与高级自定义字段插件称为'colaboradores'字段徽标(图像),direccion(字符串)和mapa(图像);WordPress自定义字段外部HTML标签

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. ?> 

所以在内容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-## --> 

一切都很好,除了direccion,这始终是外

标签与谷歌浏览器检查:

address is outside the <p> tags

我已经删除了之前的所有代码。 the_field('direccion')。 '

'; ?>但问题仍然存在。

你知道它为什么发作吗?谢谢。

+0

感谢您的回答!我发现问题:* the_field()*包括回声:[ACF - the_field](http://www.advancedcustomfields.com/resources/the_field/)[/ link],最终的代码是:'

' – Joss

回答

1

我不能确定开发工具不能显示任何不寻常的东西,但也许尝试在某些标签中包装the_field以确保没有什么不寻常的东西可以通过。

<?php echo '<p>' . strip_tags(trim(the_field('direccion'))) . '</p>'; ?>

我把带标签的存在,因为这就是通常为什么Chrome和其他浏览器会把内嵌标签像AP标签

比其他的内容之外,也许尝试让WordPress的格式段落标签,看看它是否运行,然后

<?php echo apply_filters("the_content",get_field('direccion')); ?>

看看它们中的工作吗?