我有下面的代码(不是我自己写的),其中填充了li数据值-但是这不会显示在产品页面上的日期旁边,日期显示正确,但选择下拉列表时位置不会显示。
这比我所知的要高得多,函数php文件中有很多代码我不理解,所以我想知道是否有什么明显的东西?
使用此代码的示例页面为here
<div class="custom-meta-field">
<div class="input-group">
<input type="hidden" id="datebox" class="form-control">
<input type="hidden" id="locationbox" class="form-control">
<div class="input-group-btn open">
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
Select Booking Date
<span class="fa fa-caret-down"></span>
</button>
<ul id="demolist" class="dropdown-menu">
<li data-value="Norwich, Norfolk" style="
width: 100%;
"><a href="#">Sunday, 09 January 2022</a></li>
<li data-value="Leicester"><a href="#">Friday, 29 October 2021</a></li>
</ul>
</div>
</div>
</div>
下面是php函数的代码。我可以看到这是在哪里生成的,但我不知道如何在页面上描绘位置,使其可见。function custom_meta_option() {
$_date1 = get_post_meta(get_the_ID(),\'_date1\', true);
$_date2 = get_post_meta(get_the_ID(),\'_date2\', true);
$_date3 = get_post_meta(get_the_ID(),\'_date3\', true);
$_location1 = get_post_meta(get_the_ID(),\'_location1\', true);
$_location2 = get_post_meta(get_the_ID(),\'_location2\', true);
$_location3 = get_post_meta(get_the_ID(),\'_location3\', true);
$product_id = get_the_ID();
$status = get_post_meta( $product_id, \'_stock_status\', true );
/*$terms = get_the_terms ( $product_id, \'product_cat\' );
foreach ( $terms as $term ) {
echo $cat_id = $term->term_id;
}*/
if($status == \'instock\' && !empty($_date1) || !empty($_date2) || !empty($_date3))
{
?>
<div class="custom-meta-field">
<div class="input-group">
<input type="hidden" ID="datebox" Class="form-control"></input>
<input type="hidden" ID="locationbox" Class="form-control"></input>
<div class="input-group-btn">
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
Select Booking Date
<span class="fa fa-caret-down"></span>
</button>
<ul id="demolist" class="dropdown-menu">
<?php if($_date1): ?>
<li data-value="<?php echo $_location1; ?>"><a href="#"><?php echo $_date1; ?></a></li>
<?php endif; if($_date2):?>
<li data-value="<?php echo $_location2; ?>"><a href="#"><?php echo $_date2; ?></a></li>
<?php endif; if($_date3):?>
<li data-value="<?php echo $_location3; ?>"><a href="#"><?php echo $_date3; ?></a></li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
<?php
}
//echo \'<p>No dates currently available</p>\';
}