Support » Fixing WordPress » Need help about get_the_content() function

  • Resolved Aakash83

    (@aakash83)


    I want to add a code in my theme’s header.php file which generates value for og:image(facebook meta tag) . here is the code

    <meta property ="og:image" content ="<?php $youtubeid = get_the_content();
    $url = parse_url($youtubeid);
    parse_str($url['query']);
    echo 'http://img.youtube.com/vi/'.$v.'/1.jpg';?>" />

    The above code is working fine in other theme files and I am using this method to generate thumbnails for videos .but it is not working in header.php

    but by using this code the fucntion get_the_content() does not assign any value to $youtubeid when used in header.php file (at all other places it is working good) .
    However the following code works perfect .I used a custom field and used get_post_meta() function and it is working fine.

    <meta property ="og:image" content ="<?php $youtubeid = get_post_meta($post->ID, "video", true);
    $url = parse_url($youtubeid);
    parse_str($url['query']);
    echo 'http://img.youtube.com/vi/'.$v.'/1.jpg';?>" />

    can somebody guide me how to solve this issue. I want the first code with get_the_content() function to work .

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help about get_the_content() function’ is closed to new replies.