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.

1
  • 2
    You are not using url as variable, like this $url Dec 7, 2013 at 13:00

2 Answers 2

0

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

1
  • Why you need single quotes? Dec 7, 2013 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.