I have created a custom field named ‘end_date’ which is used to display all news published before this date. So these news are considered as latest news.For latest news i have set the image width as 600px so tht i can identify they are getting into latest news. But the problem is they arent getting in. so i tried var dumping the enddate variable and its returning ” eventhough its entering in the database. Please help

$news = wp_get_recent_posts($args,false);
    echo "<div class='row'>";
    foreach( $news as $row)
    {
      $newsid=$row->ID;
      $main = get_post_meta($newsid,'main_story',true);
      if($main)
        {
          $flage=1;
          $id=$newsid;
        }
     }

     if($flage==1)
     {
      $type='Ymd';
      $time=current_time($type);
      $enddate=get_post_meta($newsid,'end_date',true);

      var_dump($enddate);

      if($time <= $enddate)
      {
        echo "<div class='row'>";
        $image = get_post_meta($newsid,'_thumbnail_id',true);



        echo "<div class= 'col-lg-4'><table style='width:200px;'><tr><td><img src='". wp_get_attachment_image_src($image)[0]."'style='width:600px;'></td></tr>";

Read more here: Custom field not giving any return value


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: