So I just found out that you can’t run PHP inside of a PHP echo (yes silly of me)
So I can’t think of an alternative way to run this script, perhaps making a variable?
It’s a wordpress php script within a php script
<?php if ( !is_user_logged_in() ) {
echo '<a href=" <?php echo get_site_url(); ?>/login" class="typcn typcn-key-outline">Log in</a>';
}
else {
echo '<a href="<?php echo get_site_url(); ?>/wp-login.php?action=logout" class="typcn typcn-key-outline">Log out</a>';
} ?>
Okay, there are few mistakes in this script.
First of all, you are using php tags inside php tags, it doesn’t make sense, you are already using php so you don’t need those php tags.
But even if you remove the php tags it won’t work because you are inside a string, so you are asking php to write litteraly get_site_url() (you are not calling get_site_url(), you are litteraly writing get_site_url())
What should you do then ?
Lets see how concatenation work first. The concatenation operator is “.”. It allows to concatenate two string.
Example :
Okay now lets do the same with variable.
This is everything you need here.
Lets see how we can solve your problem then,
what you want as a result is :
Now we replace yourSiteUrl with the concatenation operator and the php function. And you have :
Repeat the process and you’ll end up with this :
Hope the english isn’t too bad