1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Add Wordpress Post Title In Feed Url When Calling In Php

Discussion in 'PHP' started by ian_batten, Jan 28, 2013.

  1. #1
    I'm using a piece of code to display images from a google image search using Pipes, with a specific keyword as the search term. However, I would like to set this keyword as the post tile of the wordpress post.
    I currently have the following:


     <?php
     
    $maxItems = 15;
     
    $Document = new DOMDocument();
    $Document->load('http://pipes.yahoo.com/pipes/pipe.run?_id=a&_render=rss&q=keyword&safe=active');
     
    $NodeList = $Document->getElementsByTagName('item');
     
    $i = 0;
    foreach ($NodeList as $Node) {
    if ($i++ >= $maxItems) {
        break;
    }
     
    $media = $Node->getElementsByTagNameNS('http://search.yahoo.com/mrss/', 'thumbnail');
    if ($media->length > 0) {
        $imageUrl = $media->item(0)->getAttribute('url');
     
     
    echo "<img src=\"$imageUrl\n\"/>";
    } else {
        echo "No media:content\n";
    }
    } ?>
    PHP:
    In this line:

    $Document->load('http://pipes.yahoo.com/pipes/pipe.run?_id=a&_render=rss&q=keyword&safe=active');
    PHP:

    I would like to change where it says keyword, to use the get_the_title() wordpress function to search for the post title.
    Any ideas on how I would do this?
    Many thanks.
    SEMrush
     
    Solved! View solution.
    ian_batten, Jan 28, 2013 IP
    SEMrush
  2. riteshsanap

    riteshsanap Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    3
    Trophy Points:
    118
    #2
    you can use that tag but it wont work unless it is used in a loop, otherwise it is perfect,
     
    riteshsanap, Jan 28, 2013 IP
  3. ian_batten

    ian_batten Well-Known Member

    Messages:
    1,991
    Likes Received:
    106
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Sorry but that post doesn't help me at all.
     
    ian_batten, Jan 29, 2013 IP
  4. sufyyy

    sufyyy Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    8
    #4
        $Document->load('http://pipes.yahoo.com/pipes/pipe.run?_id=a&_render=rss&q=get_the_title()&safe=active');
    
    PHP:
     
    sufyyy, Jan 29, 2013 IP
  5. ian_batten

    ian_batten Well-Known Member

    Messages:
    1,991
    Likes Received:
    106
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Unfortunately that doesn't work.
     
    ian_batten, Jan 29, 2013 IP
  6. #6
    then i guess this is the solution
    $Document->load('http://pipes.yahoo.com/pipes/pipe.run?_id=a&_render=rss&q='.get_the_title().'&safe=active');
    PHP:
     
    riteshsanap, Jan 29, 2013 IP