• I’m encountering weird issues I got a page where it list all the videos so if you click the video you will be redirected into single-page-video where you see the information of the video and custom fields.

    I tried to codes this one is I’m not able to echo or get the custom fields.

    $postid = get_the_ID();
        $vidtemss = get_post_meta($post_id , 'thai-videos', true );
    
        if(!empty($vidtemss))
        {
            foreach ($vidtemss as $link) {
    
      $vidcontent = get_the_content();
               $viddate = get_the_time('F d, Y');
    
               $vidurl = $link['yt-url'];
    
            }
        }

    But this one I’m able to get the custom fields but the problem is I can’t get the the_content or get_the_content(). the_title is working well.

    $vidtemss = get_post_meta($post->ID, 'thai-videos', true );
        if(!empty($vidtemss))
        {
            foreach ($vidtemss as $link) {
    
      $vidcontent = get_the_content();
               $viddate = get_the_time('F d, Y');
    
               $vidurl = $link['yt-url'];
    
            }
        }
Viewing 7 replies - 1 through 7 (of 7 total)
  • What are you expecting get_the_content() to do? I’m a little confused. If you expect it to print a video player, it isn’t going to do that. You have to handle creating the video player in the template.

    Thread Starter freerunning

    (@freerunning)

    I’m expecting to get the body of the article/custom post I created.

    Thread Starter freerunning

    (@freerunning)

    I even tried using the_content(); but it is not working.

    Is it inside the loop? Because those template tags only work inside the loop.

    Thread Starter freerunning

    (@freerunning)

    no sir. But why is that the the_title() is working even it is not inside the loop.

    Sorry sir I’m new to wordpress kindly guide me please. Thank you!

    That will only work for the page title, because it is the queried object, if you tried that on the videos It shouldn’t work. I’m not sure though, I would have to see the context of it to say for sure.

    See: http://codex.wordpress.org/The_Loop

    Thread Starter freerunning

    (@freerunning)

    I fixed it by adding have post before the content. Thanks sir!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Getting custom fields and contents from a single page’ is closed to new replies.