当我尝试在页面上显示NULL
字段时,我得到'status'
。当我执行var_dump
时,它也会显示NULL。不知道出什么问题了。
我正在尝试在图像覆盖类中显示文本。
其他所有var都显示没有问题。
我尝试过status ==和status = etc,但是似乎没有任何作用,我必须缺少一些东西。
<?php
unset($bed); unset($type); unset($salerent); unset($pricemin); unset($pricemax); unset($status);
$salerent = 'sale';
$salerent2 = 'rent';
$type = 'villa'; $type2='condo'; $type3='house'; $type4='land';
$status = 'NEW'; $status2='SOLD'; $status3='HOT DEAL';
$bed = 'all';
$minprice='0';
$maxprice='999999999';
if ($bed=='all')
{
$bed1=1;$bed2=2;$bed3=3;$bed4=4;$bed5=5;
$bed6=6;$bed7=7;$bed8=8;$bed9=9;$bed10=10;
}
if ($salerent=='rent'){
$p0text="Price (per month)";
$p1text="0 - 10,000";
$p2text="10,000 - 25,000";
$p3text="25,000 - 40,000";
$p4text="40,000 - 80,000";
$p5text="80,000+";
}
else{
$p0text="Price";
$p1text="0 - 3 mill";
$p2text="3 - 6 mill";
$p3text="6 - 10 mill";
$p4text="10 - 20 mill";
$p5text="20+ mill";
}
?>
<?php wp_head(); ?>
</head>
<body>
<?php include( get_template_directory() . '/menu.php'); ?>
<!-- Main-->
<main>
<!-- Main Container-->
<div class='container '>
<div class="row" style="vertical-align:bottom;">
<div class="col-lg-12 col-md-12 text-center">
<h1 class="hometitle"><span style="font-size:1.1em; color:red; position:absolute; margin-left:-4px; margin-top:-19px; transform: rotate(25deg);">/</span>star property<br /><span class="mainsub"> Villas, Condos & Houses for Sale & Rent in Hua Hin</span></h1>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 center-on-small-only text-center">
<div class="row searchbox">
<div class="col-lg-12">
<form id="searchurl" method="POST" action="http:// .com/search-result/?">
<span class="filter">Search:</span>
<select class="custom-select mysearch" id="salerent" name="salerent">
<option value="sale" <?php if($salerent=='sale'){echo "selected";}?>>Sale</option>
<option value="rent" <?php if($salerent=='rent'){echo "selected";}?>>Rent</option>
</select>
<select class="custom-select mysearch" id="type" name="type">
<option value="villa" <?php if ($type=='villa'){echo "selected";}?>>Villa</option>
<option value="condo" <?php if ($type=='condo'){echo "selected";}?>>Condo</option>
<option value="house"<?php if ($type=='house'){echo "selected";}?>>House</option>
<option value="house"<?php if ($type=='land'){echo "selected";}?>>Land</option>
<option value="house"<?php if ($type=='commercial'){echo "selected";}?>>Commercial</option>
</select>
<select class="custom-select mysearch" id="bed" name="bed">
<option value="all">Bedrooms</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<select class="custom-select mysearch" id="pricerange" name="pricerange">
<option id="p0" value="all"><?php echo $p0text;?></option>
<option id="p1" value="1"><?php echo $p1text;?></option>
<option id="p2" value="2"><?php echo $p2text;?></option>
<option id="p3" value="3"><?php echo $p3text;?></option>
<option id="p4" value="4"><?php echo $p4text;?></option>
<option id="p5" value="5"><?php echo $p5text;?></option>
</select>
<input class="col-lg-1 col-md-1 mysearch" type="text" id="searchid" name="searchid" placeholder="#ID/Project" />
<button type="submit" onclick="document.getElementById('searchurl').submit();" id="submitbutton" class="btn btn-primary btn-md">SEARCH</button>
</form>
</div>
</div>
</div>
</div>
<div class="row zero col-lg-12 col-md-12 text-center">
<h2 style="width:100%; margin:0.8em 0 0.8em 0;">New Listings:<br /><span class="sub"> Properties for Sale & Rent in Hua Hin</span></h2>
</div>
<div class="row" style="padding:0; margin:0;">
<?php
$args = array(
'posts_per_page' => 6,
'post__in' => array(22094, 16782, 20898, 19838, 22150, 1442, 1794),
'post_type' => 'post',
'no_paging' => true,
'order' => DESC,
'cat' => 2,
);
// query
$the_query = new Wp_Query( $args );
?>
<ul id="starlistings" class="col-lg-12 col-md-12 row" >
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li class="col-lg-6 col-md-6" style="float:left; ">
<div class="col-lg-12 col-md-12 listingframe" >
<div class="row" style="background-color:#77c0ff" "padding-top: 20px; padding-bottom: 20px">
<div class="text-center col-lg-12 col-md-12">
<a class="listingslink" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
</div>
<div class="row" style="padding-top:0.8em;">
<div class="text-center col-lg-12 col-md-12" class="zero">
<a href="<?php the_permalink(); ?>"><img src="<?php the_field('image_1'); ?>" class="w-100" alt="<?php the_field('image_1_alt'); ?>" title="<?php the_field('area_project'); ?> <?php $type = get_field('type'); if ($type=='Villa') echo 'House'; else { the_field('type');} ?> for <?php the_field('sale_or_rent'); ?> in Hua Hin">**<div class="image-overlay"><?php $status = get_field('status'); if ($status=='NEW') echo 'NEW ARRIVAL'; else { the_field('status');} ?></div>**</a>
</div>
</div>
</div>
<div class="text-center listingsdivider col-lg-12 col-md-12">
<span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0;">ID #<?php the_field('property_id'); ?></span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0;"><?php $price = get_field('Price'); echo number_format($price, 0, '', ','); ?> baht<?php $saleorrent = get_field('sale_or_rent'); if($saleorrent=='Rent'){echo ' ';} ?>
</span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0.5em;"><img src="/wp-content/themes/startheme/images/house.png" alt="house" style="height:12px; width:auto; margin:-4px 8px 0 0; padding:0; opacity:0.7" /><?php the_field('living_space'); ?> SQM</span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0.5em;"><img src="/wp-content/themes/startheme/images/beds.png" alt="bedrooms" style="height:12px; width:auto; margin:-2px 4px 0 -3px; padding:0; opacity:0.6" /><?php the_field('bedrooms'); ?> Beds</span>
<span style="padding:5px 0 5px 0.5em; "><img src="/wp-content/themes/startheme/images/bathrooms.png" alt="bathrooms" style="height:15px; width:auto; margin:-2px 6px 0 2px; padding:0; opacity:0.6;" /><?php the_field('bathrooms'); ?> Baths</span>
</span>
<div style="background-color: white; padding-top: 10px; padding-bottom: 5px"><span><?php $excerpt = wp_trim_words( get_field('property_description' ), $num_words = 10, $more = '<a href="'.get_permalink().'">... more</a>' ); echo $excerpt; ?></span></div>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
答案 0 :(得分:0)
好的,我已经解决了问题。
我希望这将对遇到相同问题的所有人有所帮助。
将wp-admin中的字段添加到“高级自定义字段”字段组中。
确保将“返回值”更改为“值”。
标签和双向/数组不适用于get_field或the_field。
希望这对某人有帮助。