View Full Version : Variables in echo statement with array.

09-22-2009, 10:45 AM
I'm trying the following PHP in a wordpress page template and not having too much luck. Ideally it should output a H2 with Twitter + the page title and then the 10 last posts on twitter related to the page title. I am guessing cause its an echo.

<h2><a rel="nofollow" href="http://www.twitter.com">Twitter <?php the_title(); ?> </a></h2>
echo SimplePieWP('http://search.twitter.com/search.atom?q=<?php the_title(); ?>
', array(
'items' => 10,

Anyone ?

Phil Jackson
09-22-2009, 11:00 AM
id have to see the functions but this should help

<?php echo SimplePieWP("http://search.twitter.com/search.atom?q=".the_title(), array("items" => 10)); ?>

09-22-2009, 11:53 AM

I dropped that in and it didnt work.

What functions do you need to see ?

Whats good to debug ? or see errors ?


09-22-2009, 11:57 AM
All it is outputting now is the title. Any other syntax ?


Phil Jackson
09-22-2009, 12:31 PM
i need to know what this function does: SimplePieWP(); and the_title();

09-22-2009, 01:16 PM
Its a Wordpress site.

So, the_title(); pulls the Page Title &

SimplePieWP(); see;


Is that what you need ?

Phil Jackson
09-22-2009, 01:22 PM
see i dont use word press.
I need to know what this function does to know how to help you.

SimplePieWP($addressOrSomeSort, $andThisIsSomething);

Do you understand what i mean?

Phil Jackson
09-22-2009, 01:25 PM
echo SimplePieWP("http://search.twitter.com/search.atom?q=".the_title(), array('items' : 10));

should limit the number of posts returned to 10.

09-22-2009, 01:27 PM
yeah on the link under parameters about half way down.


09-22-2009, 01:30 PM
ok I got it displaying now using, this..... but its not right. its now searching .the_title() instead of the name of the page.

<?php echo SimplePieWP('http://search.twitter.com/search.atom?q=.the_title()', array("items" => 10)); ?>

09-22-2009, 01:47 PM
just tried another RSS feed and it too is displaying feeds with "title" in them

Phil Jackson
09-22-2009, 02:39 PM
try (copy and paste)

$title = the_title();
echo SimplePieWP("http://search.twitter.com/search.atom?q=$title",
array('items' : 10));

09-22-2009, 03:17 PM
i actually just worked it out in the end. thanks for all your help Phil.

<?php echo SimplePieWP (array(
'http://search.twitter.com/search.atom?q=' . urlencode ( the_title ( '' , '' , false ) ) . ''
),array( 'items' => '6' )); ?>