【问题标题】:ACF not showing correctly in wordpress twenty fourteen themeACF 在 wordpress 二十十四主题中未正确显示
【发布时间】:2014-02-15 15:51:22
【问题描述】:

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

我使用的主题是二十四。下面是我放置字段的循环

<?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('field name') \n;但它不起作用。以及如何使字段名称也出现?

请帮忙,我将不胜感激。

阿尔塞夫

【问题讨论】:

    标签: advanced-custom-fields


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-26
      • 2013-06-04
      • 2014-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 2015-11-29
      相关资源
      最近更新 更多