0

I'm tring to use str_replace within a wordpress function but its not working.

My code:

function fields($content) {
    if(is_feed()) {  
    $post_id = get_the_ID();
    $url = str_replace('http://', '', '' . get_post_meta($post_id, 'book-author', true) . ''); 
    $output = '<div>';
    $output .= '' .url. '';
    $output .= '</div>';
    $content = $content.$output;  
    }  
    return $content;  
}
add_filter('the_content','fields');

What I'm getting in result of ' .url. ' is just "url" printed in my feed. Please help.

Thank you.

closed as off-topic by s_ha_dum, fuxia Dec 7 '13 at 16:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You are not using url as variable, like this $url – Nicolai Dec 7 '13 at 13:00
0

That could not work, you simply miss the $ before $url. $output .= '' .$url. '';

  • Why you need single quotes? – Chittaranjan Dec 7 '13 at 14:08
0

You can directly assign the url variable to the output variable as below.

$output .= $url;

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