WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

this is a silly question, but i dont know, can anyone help me out in this

i want to echo get_post_meta() on a url, but i am getting parse error i am having a function, where in the between of url one field can be filled by the value of custom field

here is the code

($doc->load('http://twitter.com/statuses/user_timeline/' . . '.rss'));

the space between . . there i want to echo the value of my get_post_meta value,

but if i write something like this

($doc->load('http://twitter.com/statuses/user_timeline/' .echo get_post_meta() . '.rss'));

i know this step is wrong, then too i tried, i get parse error

how can i echo it???

share|improve this question
leave out echo . btw a meta key argument is required from what I remember – onetrickpony Dec 17 '10 at 14:13
Yea, leave out echo but you need more than just get_post_meta. It has to be get_post_meta($post->ID, 'change-this-to-your-meta-field', true); – eileencodes Dec 17 '10 at 14:56
up vote 3 down vote accepted

Remove the echo. In PHP, you only use echo when you want to send the result as text to the browser. If you want to use the value in PHP (like you are trying to do), then you leave out the echo and add $post->ID, 'meta_field_you_want', true to get_post_meta();

share|improve this answer
that i tried then i am getting error, the custom field has the value which has to go into the url, and i have given $post->ID and other things but i am getting error i have to echo it so that i get that value – ntechi Dec 17 '10 at 16:07
<code>$meta = get_post_meta($post->ID, 'your_key', true); $feed = "twitter.com/statuses/user_timeline/$meta.rss";; $doc->load($feed); </code> – Don Gilbert Dec 17 '10 at 17:34
Might want to add some error handling, too: if ( $meta = get_post_meta($post->ID, 'your_key', true) ) { $feed = "http://twitter.com/statuses/user_timeline/$meta.rss"; $doc->load($feed); } ... so it doesn't break if that key isn't present. – goldenapples Dec 17 '10 at 21:33
thanks it worked – ntechi Dec 18 '10 at 5:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.