0

Im am trying to add a php to dynamically display rss within the search results pages on my WordPress site. The $XMLFILE below is suppose to have the url to the rss feed I want to display.

$XMLFILE = "http://www.bing.com/search?q=SEARCH-QUERY-GOES-HERE&format=rss";

Now, the thing is I want to use another php in the $XMLFILE where it says SEARCH-QUERY-GOES-HERE. Like this example:

$XMLFILE = "http://www.bing.com/search?q=<?php printf( __( '%s', 'twentytwelve' ), '' . get_search_query() . '' ); ?>&format=rss";

Problem is, how do I put php inside of this to complete the url?

This php I got from wordpress and display the search term searched on the site

<?php printf( __( '%s', 'twentytwelve' ), '' . get_search_query() . '' ); ?>

SO now I have been trying to put the two together so when the user searches may APPLES it will show in the $XMLFILE where it say SEARCH-QUERY-GOES-HERE the word APPLES and therefore displays the rss for the keyword APPLES. APPLES is just the example keyword I used to try to illustrate what I am asking.

Get what I am asking? ANyone know how to add php inside php like this or a better option to add a Wordpress search term into $XMLFILE where it says SEARCH-QUERY-GOES-HERE?

Thanks in advance!

2
  • You can't embed PHP in PHP like that, unless you're using eval(). And as a general rule, eval() is an evil ugly tool that should never be used - it WILL blow up on you horribly at some point. Commented Jul 1, 2013 at 22:13
  • @Frederik answered the question just fine and his response worked. Thanks anyways guys. No need to use eval() code :) Commented Jul 1, 2013 at 22:40

1 Answer 1

1

Assuming I understand this question, you could do something like this:

$more = __( get_search_query(), 'twentytwelve' );
$XMLFILE = "http://www.bing.com/search?q=$more&format=rss";

In double-quotes, variables can be placed inline. As done above. You can then run __() above, and put the result in a variable. This will get the wanted result.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.