Support » Plugins » Hacks » Extract domain from permalink

  • Resolved gamedriver

    (@gamedriver)


    I´m some kind of a noob concerning php and maybe my problem is more than simple.

    I try to extract the domain from a permalink. If you have “www.test.com/test.html” it should write http://www.test.com. I´d like to put this under my posts.

    Till know I tried the following piece of code inside my single.php, but nothing appears:

    <?php $url = ‘<?php the_permalink() ?>’;
    $parse = parse_url($url);
    print $parse[‘host’];
    ?>

    Is anyone out there to help me? Any help would be really appreciated.

    Thank you, friends!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter gamedriver

    (@gamedriver)

    Thank´s for your hint, but I guess you got me wrong.

    I don´t need to get my blog´s domain shown. My articles are generated by a feedreader and the article´s headlines (and permalinks) are pointing to the original article source. Now I need a little snippet which shows me only the domain of the original source.

    You should be using get_permalink() instead of the_permalink() which echo directly.

    Also, you’re probably confused by the way intermingled way WordPress is coded. The php tags <?php and ?> are only at the beginning and end of each code block, they cannot/should not be nested.

    Try $url=get_permalink();

    Thread Starter gamedriver

    (@gamedriver)

    Thank´s a lot Xephan!!! You solved my problem. Everything is working fine now. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Extract domain from permalink’ is closed to new replies.