Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Newbie question - Coding HTML within PHP

    Hi guys.

    I'm afraid it's a terribly simple problem but basically I have an RSS new feed on my site and I'd like a new window to open when the user clicks the link to the news story. Everything except the new window problem is working ok - here's the code I have:
    Code:
    <?php
    require_once (ABSPATH . WPINC . '/rss-functions.php');
    
    $url = 'http://www.onestopclick.com/rss/Industry-News.xml';
    $rss = fetch_rss( $url );
    if ( $rss ) {
    echo "<p>";
    $i = 1;
    foreach ($rss->items as $item) {
    $href = $item['link'];
    $title = $item['title'];
    $description = $item['description'];
    echo "<a href=$href>$title</a>
    <br />$description<br />";
    if ($i == 2 ) break;
    $i = $i + 1;
    }
    echo "</p>";
    }
    ?>
    I know I need to use target="_blank" somewhere but I don't know where to put it.

    Thanks in advance.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Change
    PHP Code:
    echo "<a href=$href>$title</a> 
    to
    PHP Code:
    echo "<a href=\"$href\" target=\"_blank\">$title</a> 
    Last edited by Inigoesdr; 03-07-2008 at 06:33 AM.

  • Users who have thanked Inigoesdr for this post:

    kendalbren (03-07-2008)

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    I'm not fluent in PHP, but maybe adding target="_blank" in the <a> tag might help.
    Code:
    echo "<a href=\"$href\" target=\"_blank\">$title</a>
    <br />$description<br />";
    See if it helps
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks a lot guys. Super fast response too!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •