Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i have add facebook opengraph tag

now it showing error like

Call to undefined function wp_get_attachment_src()

Object at URL 'http://www.website.com' of type 'article' is invalid because the given value ': Call to undefined function wp_get_attachment_src() in on line Fatal error ...... functions.php123 ' for property 'og:image:url' could not be parsed as type 'url'.

using this code in header.php

<meta property="og:image" content="<?php echo get_fbimage(); ?>" />

in function.php

<?php
function get_fbimage() {
$src = wp_get_attachment_src( get_post_thumbnail_id($post->ID), '', '' );
if ( has_post_thumbnail($post->ID) ) {
$fbimage = $src[0];
} else {
global $post, $posts;
$fbimage = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',
$post->post_content, $matches);
$fbimage = $matches [1] [0];
}
if(empty($fbimage)) {
$fbimage = "http://www.gogirlfinance.com/wp-content/uploads/2011/03/logo.jpg";
}
return $fbimage;
}
?>

Note: I am using same code/ function in other website with no issue

share|improve this question

1 Answer 1

I think you are looking for wp_get_attachment_image_src instead of wp_get_attachment_src which is not a core WordPress function

share|improve this answer

Your Answer

 
discard

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.