Getacho Company
Getacho Company

Reputation: 13

Wordpress Title Error

<?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>

Condition is not working properly.

can anyone help me?

Upvotes: 0

Views: 41

Answers (2)

jd182
jd182

Reputation: 3260

isset() returns a boolean, so the following line is setting $custom_store_title to either true or false:

<?php $custom_store_title = isset(appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name')); ?>

I think you might mean this instead:

 <?php $custom_store_title = appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name'); ?>

Then instead of the other isset() you probably want to use !empty() because $custom_store_title variable will always be set but may or may not be empty:

<?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>";
    }
?>

Upvotes: 0

dave
dave

Reputation: 64657

You have

$custom_store_title = isset(appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name')); ?>

Which means $custom_store_title is set to either true or false.

Then you have:

if (isset($custom_store_title)) // if (true), essentially.
{ 
  // ... 
} else { //this will never happen }

What you need is:

$custom_store_title = appthemes_get_custom_taxonomy($post->ID, APP_TAX_STORE, 'name'));
if (isset($custom_store_title)) { 
    //do stuff
} else {
    //do something else
}

Upvotes: 1

Related Questions