这里有人熟悉Twig吗?当价格字段为空时,Wordpress主题Realia应显示自定义文本字段。但它并没有。这是我认为负责的代码。
<div class="property span9">
<div class="row">
<div class="image span3">
<div class="content">
<a href="{{ wp.get_permalink(property.ID) }}"></a>
{% if wp.get_the_post_thumbnail(property.ID) %}
<img src="{{ wp.aq_resize(wp.wp_get_attachment_url(wp.get_post_thumbnail_id(property.ID), 'full'), 270, 200, 'true') }}" alt="{{ property.post_title }}">
{% else %}
<img src="{{ wp.get_template_directory_uri() }}/assets/img/property-tmp-small.png" alt="{{ property.post_title }}">
{% endif %}
</div>
<!-- /.content -->
</div>
<!-- /.image -->
<div class="body span6">
<div class="title-price row">
<div class="title span4">
<h2><a href="{{ wp.get_permalink(property.ID) }}">{{ property.post_title }}</a></h2>
</div>
<!-- /.title -->
<div class="price">
{% if wp.get_post_meta(post.ID, '_property_custom_text').0 %}
{{ wp.get_post_meta(post.ID, '_property_custom_text').0 }}
{% else %}
{{ wp.aviators_price_format(property.meta._property_price.0) }}{% if property.meta._property_price_suffix.0 %}
<span class="suffix">{{ property.meta._property_price_suffix.0 }}</span>{% endif %}</div>
{% endif %}
<!-- /.price -->
</div>
<!-- /.title -->
<div class="location">{{ property.location.0.name }}</div>
<!-- /.location -->
<div class="body">
{{ wp.aviators_core_get_post_teaser(property.ID) }}
</div>
<!-- /.body -->
<div class="info clearfix">
{% if property.meta._property_area.0 %}
<div class="area">
<span class="key">{{ wp.__('Area', 'aviators') }}:</span><!-- /.key -->
<span class="value">{{ property.meta._property_area.0 }}{{ wp.aviators_settings_get_value('properties', 'units', 'area')|raw }}</span><!-- /.value -->
</div><!-- /.area -->
{% endif %}
{% if property.meta._property_bedrooms.0 %}
<div class="bedrooms" title="{{ wp.__('Bedrooms', 'aviators') }}">
<div class="content">{{ property.meta._property_bedrooms.0 }}</div>
</div><!-- /.bedrooms -->
{% endif %}
{% if property.meta._property_bathrooms.0 %}
<div class="bathrooms" title="{{ wp.__('Bathrooms', 'aviators') }}">
<div class="content">{{ property.meta._property_bathrooms.0 }}</div>
</div><!-- /.bathrooms -->
{% endif %}
</div>
<!-- /.info -->
</div>
<!-- /.body -->
</div>
<!-- /.row -->
</div><!-- /.property -->
答案 0 :(得分:1)
尝试:
{% if property.meta._property_price_suffix == false %}
http://twig.sensiolabs.org/doc/tags/if.html文档末尾的表非常有用。