Support » Themes and Templates » Request URI

  • Resolved caylean


    I was thinking this would be an easy Task, i still believe it is, but without PHP knowledge it is impossible to do correctly.

    I try to add to an Link the active uri.

    <a onclick="popUpWin(this.href, 'console', 660, 425, 50, 50);return false;" href="<?php echo $_SERVER['REQUEST_URI']; ?>"><img src="<?php bloginfo('url'); ?>/images/facebook.png" alt="Facebook" width="20" height="20" border="0" /></a>

    If a user is on the main site he has the correct url in the Link, if he is in a posting he also has it.

    But whatever i Try like this Actual Code i posted above, or this

    if (is_home())
    echo “<?php bloginfo(‘url’); ?>”;
    else {
    echo “<?php the_permalink() ?>”;

    instead of <?php echo $_SERVER[‘REQUEST_URI’]; ?> — it all isn’t function, could someone tell me where i do wrong? and how I could fix that, without using any kind of Plugin?

    Kind Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • This…

    if (is_home())
    echo "<?php bloginfo('url'); ?>";

    … will echo the literal string “<?php bloginfo(‘url’); ?>”. You don’t need to quote your argument and add a PHP block. You are already ‘in’ PHP. You are also missing a ‘{‘. That should be…

    if (is_home()) {
    echo bloginfo('url');

    THanks, thats it! 🙂

    <?php if (is_home()) { echo bloginfo('url'); } else { echo the_permalink(); } ?>

    and it is all fine. This missing { comes due to the fact i know nothing about php 🙂

    Just for some cosmetics in the echo bloginfo(‘url’) — Is it possible to add an / in the end to the Link? Now it is just http://test.domain.tld

    But all in all it is resolved, thanks.

    Yes, just tack it on bloginfo('url').'/';

    Hehe, thats indeed very easy, if you know that there yould be .’ before and a ‘ behind it *g*
    Without it, you generate again just crap 😉

    Thanks s_ha_dum for your kindness and fast help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Request URI’ is closed to new replies.