我是php
的新手,但努力学习,我无法弄明白。
这里的原始代码带有一个值我正在工作:
$description = get_post_meta($post->ID, "description", false);
if ($description[0]=="") {
<!-- If there are no custom fields, show nothing -->
} else {
<div class="wrap">
<h3>Products</h3>
foreach($description as $description) {
echo '<p>'.$description.'</p>';
}
</div>
}
我很难修改此代码,以便从多个自定义字段输入中检索值并将它们放在一起并放在一起。
以下是添加了一个值的代码,但是如何组合thoose 2值:
$description = get_post_meta($post->ID, "Description", false);
$seccond_value = get_post_meta($post->ID, "price", false);
<?php
if ($description[0]=="") {
?>
<strong> how do i combine 2 values here?</strong>
<!-- If there are no custom fields, show nothing -->
<?php
} else {
?>
<div class="wrap">
<h3>products</h3>
<strong>// how does this part work and how to i combine 2 values here?</strong>
<?php
foreach($description as $description) {
echo '<p>'.$description.'</p>';
}
?>
</div>
}
也许这里的某个人有一个很好的提示,可以解决上面的问题吗?
答案 0 :(得分:0)
试试这个
if ($description[0] != "" && $seccond_value[0] != "") {
// Combine two values and print them
} else {
// Value is not set
}