techvagabond
asked on
Wordpress PHP if Statement not working correctly
Below I have a piece of code in which I'm certain I'm doing something very stupid, as does come with working on a Saturday.
I have in my functions.php a declared true/false variable. If the drop down is set to yes, or true, then it does display the text "Test" and then input the code for the wordpress comment engine (The comment section does not appear)
The second part, if it is not equal to 'yes', then it returns a seperate DIV tag. This also works.
So the IF statement seems to be working, but it just does not seem to be working with the <?php comments_template(); ?> WordPress hook.
Any Ideas?
I have in my functions.php a declared true/false variable. If the drop down is set to yes, or true, then it does display the text "Test" and then input the code for the wordpress comment engine (The comment section does not appear)
The second part, if it is not equal to 'yes', then it returns a seperate DIV tag. This also works.
So the IF statement seems to be working, but it just does not seem to be working with the <?php comments_template(); ?> WordPress hook.
Any Ideas?
<?php if (get_option('console_engine') <> 'yes')
{
echo "Test <?php comments_template(); ?>";
}else{
echo "<div id='test-root'></div>";
}?>
ASKER
you're right, in the code generated in just puts in
test<?php comments_template(); ?>
Firefox source browser gives the php statement a pink colour which I've never seen before. I think it's taunting me.
Basically, that php hook is what you call to be able to leave or view comments on a particular wordpress page of blog post.
I'm trying to make it so that in the functions.php, the user has an option to turn the comment engine off if required.
test<?php comments_template(); ?>
Firefox source browser gives the php statement a pink colour which I've never seen before. I think it's taunting me.
Basically, that php hook is what you call to be able to leave or view comments on a particular wordpress page of blog post.
I'm trying to make it so that in the functions.php, the user has an option to turn the comment engine off if required.
The pink means "What is this?", means Firefox doesn't recognize it. Putting it in the 'echo' won't do what you want because it never gets executed. I don't know where you need to put it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That looks like it'll do the trick :D
Champion
Champion
echo "Test <?php comments_template(); ?>";
puts the "<?php comments_template(); ?>" in the HTML code where it does nothing. It does not get executed by PHP. What is it supposed to do?