<?php $custom_store_title = isset(appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name')); ?>
<head>
<?php if (isset($custom_store_title))
{
echo "<title>".$custom_store_title." Coupon Codes | ". $custom_store_title." Promo Codes</title>";
}
else
{
echo "<title>" . wp_title(' ') ." | ". bloginfo('name'). " </title>";
}
?>
</head>
条件无法正常工作。
谁能帮我?
你有
$custom_store_title = isset(appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name')); ?>
这意味着$custom_store_title
设置为 true 或 false。
然后你有:
if (isset($custom_store_title)) // if (true), essentially.
{
// ...
} else { //this will never happen }
您需要的是:
$custom_store_title = appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name'));
if (isset($custom_store_title)) {
//do stuff
} else {
//do something else
}
>isset()
返回一个布尔值,因此以下行将$custom_store_title
设置为 true 或 false:
<?php $custom_store_title = isset(appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name')); ?>
我想你可能的意思是:
<?php $custom_store_title = appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name'); ?>
然后,您可能希望使用其他isset()
而不是其他!empty()
因为$custom_store_title
变量将始终被设置,但可能是也可能不是空的:
<?php if (!empty($custom_store_title))
{
echo "<title>".$custom_store_title." Coupon Codes | ". $custom_store_title." Promo Codes</title>";
}
else
{
echo "<title>" . wp_title(' ') ." | ". bloginfo('name'). " </title>";
}
?>