Reputation: 1
How do I echo:
<?php the_title(); ?>
Within the variable below, after "q="
<?php
$feedURL = 'https://gdata.youtube.com/feeds/api/videos?q=<?php the_title(); ?>&orderby=published&start-index=11&max-results=10&v=2';
?>
Upvotes: 0
Views: 902
Reputation: 51
What you want to use here is get_the_title()
function.
The function you are using (the_title()
) it is used to print the value (although you can force it to just return the value, more info)
Your code would look like this:
<?php
$feedURL = 'https://gdata.youtube.com/feeds/api/videos?q=' . get_the_title() . '&orderby=published&start-index=11&max-results=10&v=2';
?>
Upvotes: 2
Reputation: 2196
You're already in php, so you don't need to open php tags again. Simply concatenate the variable on the string.
<?php
$feedURL = 'https://gdata.youtube.com/feeds/api/videos?q=' . the_title() . '&orderby=published&start-index=11&max-results=10&v=2';
?>
Edited to use . instead of + to match PHP.
Upvotes: -1
Reputation: 4620
Try this
<?php
$title = the_title();
$feedURL = 'https://gdata.youtube.com/feeds/api/videos?q='.urlencode($title).'&orderby=published&start-index=11&max-results=10&v=2';
?>
Upvotes: 0
Reputation: 3691
Something like this
<?php
$feedURL = 'https://gdata.youtube.com/feeds/api/videos?q=' . get_the_title() . '&orderby=published&start-index=11&max-results=10&v=2';
?>
Upvotes: 0