自定义字段多值、Wordpress、PHP
我对自定义字段多值、Wordpress、PHP,php,wordpress,Php,Wordpress,我对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&
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>
}
$description=get\u post\u meta($post->ID,“description”,false);
如果($description[0]==“”){
}否则{
产品
foreach($description作为$description){
回显“”.$description.“”;
}
}
我很难修改这段代码,从多个自定义字段输入中检索值,并将其放在一起或在同一个字段之间
下面是添加了一个以上值的代码,但我不知道如何组合这两个值:
$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>
}
$description=get\u post\u meta($post->ID,“description”,false);
$second\u value=get\u post\u meta($post->ID,“price”,false);
如何在此处组合两个值?
产品
//此部分如何工作以及如何在此处组合两个值?
}
也许这里有人有一个很好的sajt技巧来回答我上面的问题?试试这个
if ($description[0] != "" && $seccond_value[0] != "") {
// Combine two values and print them
} else {
// Value is not set
}