ACF输出未显示

时间:2018-02-07 11:39:04

标签: php wordpress advanced-custom-fields

我在网站上工作,但由于某种原因,我无法使用自定义字段。我使用插件高级自定义字段和WP属性。

因此WP-Property使用page.php作为列表。

page.php:

<?php get_header(); ?>
    <div id="main">
        <div id="content-full-width">
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <?php the_content(); ?>
            <?php endwhile; else: ?>

            <?php wp_reset_postdata(); ?>

            <?php endif; ?>
        </div>
        </div>
    </div>

<?php get_footer(); ?>

Property-Overview.php:

<?php
/**
 * Mark:
 * Aanbod template.
 * 
 * WP-Property Overview Template
 *
 * To customize this file, copy it into your theme directory, and the plugin will
 * automatically load your version.
 *
 * You can also customize it based on property type.  For example, to create a custom
 * overview page for 'building' property type, create a file called property-overview-building.php
 * into your theme directory.
 *
 *
 * Settings passed via shortcode:
 * $properties: either array of properties or false
 * $show_children: default true
 * $thumbnail_size: slug of thumbnail to use for overview page
 * $thumbnail_sizes: array of image dimensions for the thumbnail_size type
 * $fancybox_preview: default loaded from configuration
 * $child_properties_title: default "Floor plans at location:"
 *
 *
 *
 * @version 1.4
 * @author Andy Potanin <andy.potnain@twincitiestech.com>
 * @package WP-Property
*/?>
<?php
 if ( have_properties() ) {
   $thumbnail_dimentions = WPP_F::get_image_dimensions($wpp_query['thumbnail_size']);
?>
 <div class="<?php wpp_css('property_overview::row_view', "wpp_row_view wpp_property_view_result"); ?>">
  <div class="<?php wpp_css('property_overview::all_properties', "all-properties"); ?>">
  <?php foreach ( returned_properties('load_gallery=false') as $property) { 
    $isVerkochtVerhuurd = isset($property['verkocht_of_verhuurd']);
    $isHuur = $property["property_type"] == 'huurwoning' || $property["property_type"] == 'kamer';
    $isKoop = $property["property_type"] == 'koopwoning';
    ?>

    <div class="objectEntry">

        <div class="<?php wpp_css('property_overview::left_column', "wpp_overview_left_column"); ?>" style="">

    <div class="imgin">
          <?php property_overview_image(); ?>
    <div class="info-over-image">
        <?php the_field('flash', get_the_ID()); ?>
    </div>
    </div>

        </div>

        <div class="<?php wpp_css('property_overview::right_column', "wpp_overview_right_column"); ?>" style="">

            <ul class="<?php wpp_css('property_overview::data', "wpp_overview_data"); ?>">
                <li class="property_title">
                    <a <?php echo $in_new_window; ?> href="<?php echo $property['permalink']; ?>"><?php echo $property['post_title']; ?></a>
                    <?php if( !empty( $property['is_child'] ) ): ?>
                        <?php _e('of',ud_get_wp_property()->domain); ?> <a <?php echo $in_new_window; ?> href='<?php echo $property['parent_link']; ?>'><?php echo $property['parent_title']; ?></a>
                    <?php endif; ?>
                </li>

            <?php if( !empty( $property['display_address'] ) ): ?>
                <li class="property_address"><a href="<?php echo $property['permalink']; ?>#property_map"><?php echo $property['display_address']; ?></a></li>
            <?php endif; ?>

              <li class="kenmerkenContainer">
                 <ul class="kenmerken">
                    <?php if( !empty( $property['slaapkamers'] ) ): ?>
                        <li class="property_slaapkamers">
                            <span class="attribute"></span>
                            <span class="value"><?php echo $property['slaapkamers']; ?></span>
                        </li>
                    <?php endif; ?>
                    <?php if( !empty( $property['badkamer'] ) ): ?>
                        <li class="property_badkamers">
                            <span class="attribute"></span>
                            <span class="value"><i class="fas fa-shower"></i> <?php echo $property['badkamer']; ?></span>
                        </li>
                    <?php endif; ?>
                    <?php if( !empty( $property['area'] ) ): ?>
                        <li class="property_oppervlakte">
                            <span class="attribute">Oppervlakte:</span>
                            <span class="value"><?php echo $property['area']; ?></span>
                        </li>
                    <?php endif; ?>
                    <?php if( !empty( $property['woning_type'] ) ): ?>
<!--                        <li class="property_oppervlakte"> -->
<!--                            <span class="attribute">Woningtype:</span> -->
                            <span class="value"><?php echo $property['woning_type']; ?></span>
<!--                        </li> -->
                    <?php endif; ?>
                </ul>
            </li>


                <li class="property_price"><div><?php echo $property['price']; ?></div></li>


    <li class="btn-view"><a class="knpweergeven" href="<?php echo $property['permalink']; ?>">Bekijken</a></li>

            <?php if( $show_children && !empty( $property['children'] ) ): ?>
            <li class="child_properties">
                <div class="wpd_floorplans_title"><?php echo $child_properties_title; ?></div>
                <table class="wpp_overview_child_properties_table">
                    <?php foreach($property['children'] as $child): ?>
                    <tr class="property_child_row">
                        <th class="property_child_title"><a href="<?php echo $child['permalink']; ?>"><?php echo $child['post_title']; ?></a></th>
                        <td class="property_child_price"><?php echo isset( $child['price'] ) ? $child['price'] : ''; ?></td>
                    </tr>
                    <?php endforeach; ?>
                </table>
            </li>
            <?php endif; ?>

            <?php if(!empty($wpp_query['detail_button'])) : ?>
            <li class="detailButton"><a <?php echo $in_new_window; ?> class="button" href="<?php echo $property['permalink']; ?>"><?php echo $wpp_query['detail_button'] ?></a></li>
            <?php endif; ?>
       </ul>

        </div><?php // .wpp_right_column ?>

    </div><?php // .property_div ?>

    <?php } /** end of the propertyloop. */ ?>
    </div><?php // .all-properties ?>
    </div><?php // .wpp_row_view ?>
<?php } else {  ?>
<div class="wpp_nothing_found">
   <p><?php echo sprintf(__('Geen woningen gevonden. Klik <a href="%s">hier</a> om al het aanbod te tonen.',ud_get_wp_property()->domain), site_url().'/'.$wp_properties['configuration']['base_slug']); ?></p>
</div>
<?php } ?>

正如您所看到的,我使用以下代码从自定义字段中检索数据:

<div class="info-over-image">
    <?php the_field('flash', get_the_ID()); ?>
</div>

输出未显示。我无法找到我做错的事。原始代码是:

<p><?php the_field('field_name'); ?></p>

1 个答案:

答案 0 :(得分:0)

首先,不需要在WP-Property插件中使用高级自定义字段。 WP-Property允许根据需要创建任意数量的自定义字段,并具有不同的属性字段输入,例如:文本编辑器,下拉选择,单一复选框,多重复选框,广播,数字,货币,Oembed,文件和图像上载,URL,日期和颜色选择器等

此外,WP-Property使用property.php模板进行单个列表。

的问候。 玛利亚