PHP生成的元素忽略了div - Wordpress

时间:2014-05-17 13:34:05

标签: php html css wordpress

每当我尝试使用get_date函数时,它会忽略所有div并且正好在标题结尾之后放置 - 在<div class="entry-content">

的开头
<div class="entry-content">
            May 16, 2014
    <div class="blogleft">
        <div class="mblog">

正在将其他功能正确放置在<div class="mblog">内。

<div class="post-info">Posted on </div>

post-info已正确嵌套在所有div下,但使用the_date()生成的日期会一直返回。     

function getblogpostsmain($atts, $content = null) {
   extract(shortcode_atts(array(
      'posts' => 1,
   ), $atts));

   $return_string .= '<div class="mblog">';
   query_posts (array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts));
   if (have_posts()) :
      while (have_posts()) : the_post();
    $return_string .= '<h1 class="blog-title"><a href="'.get_permalink().'">'.get_the_title().' </a></h1>';
    $return_string .= '<div class="post-info">Posted on '.the_date().'</div>';
    $return_string .= '<p class="post-excerpt">' . get_the_excerpt() . '</p>';
endwhile;
   endif;
   $return_string .= '</div>';

   wp_reset_query();
   return $return_string;
}

?>

知道到底发生了什么事吗?我想出去了。 使用的主题:Vantage theme

1 个答案:

答案 0 :(得分:2)

您正在使用the_date(),当您需要的是一个返回日期的函数时,它会输出日期。

使用the_date()交换get_the_date()

E.g:

$return_string .= '<div class="post-info">Posted on ' . get_the_date() . '</div>';

进一步阅读:http://codex.wordpress.org/Template_Tags/get_the_date