• Call to undefined function wp_get_attachment_src()

    Object at URL ‘https://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 = "https://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

  • The topic ‘Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()’ is closed to new replies.