ACF在wordpress二十四主题中没有正确显示

时间:2014-02-15 15:51:23

标签: advanced-custom-fields

我正在尝试自定义帖子并安装了高级自定义字段插件。自定义字段显示在编辑器中,但是当我将所有the_field('fieldname')添加到单个帖子页面时,它会在帖子中显示,但它们都在一行中。

我使用的主题是Twenty Fourteen。下面是我放置字段的循环

<?php
            // Start the Loop.
            while ( have_posts() ) : the_post();


            get_template_part( 'content', get_post_format() );
            the_field('make');
            the_field('type');
            the_field('year');
            the_field('hours');
            the_field('location');
            the_field('specifications');

            // Previous/next post navigation.
            twentyfourteen_post_nav();

            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) {
                            comments_template();
                        }
            endwhile;
    ?>

在帖子上显示如下:http://www.hamburgheros.com/2014/02/12/klemm-kr-909-1/

我希望它能像这样出现:

制作:KLEMM KR 909-1 类型:钻头 年份:2012年 营业时间:100 地点:德国 产品规格: 多功能/锚钻机

Deutz Engine TCD 2013 L4 2V – 129 KW / 175 HP (EPA / TIERIII)
Crawler type B1 / 400 mm 3-grouser pads
Drill mast type 305
Hammer KD1624
Different options for double head drilling units and rotary heads
Different options for clamping and breaking devices
Remote controlled drilling functions
Second articulation cylinder
Winch
Flushing 1” / 1 ½ “
Oiler 8 l, 20 bar
Weight:  13 t

我试过the_field('字段名')\ n;但它不起作用。你如何使字段名称出现呢?

请帮助,我将非常感激。

Al Sev

1 个答案:

答案 0 :(得分:0)

the_field只返回与条目相关的数据 - 例如,您必须自己添加标签以及一些HTML来设置输出样式;

<?php
        // Start the Loop.
        while ( have_posts() ) : the_post();


        get_template_part( 'content', get_post_format() );

        ?>
        <ul>
            <li>MAKE: <?php the_field('make'); ?></li>
            <li>TYPE: <?php the_field('type'); ?></li>
            <li>YEAR: <?php the_field('year'); ?></li>
            <li>HOURS: <?php the_field('hours'); ?></li>
            <li>LOCATION: <?php the_field('location'); ?></li>
            <li>SPEC: <?php the_field('specifications'); ?></li>
        </ul>

        // Previous/next post navigation.
        twentyfourteen_post_nav();

        // If comments are open or we have at least one comment, load up the comment template.
        if ( comments_open() || get_comments_number() ) {
                        comments_template();
                    }
        endwhile;
?>
相关问题