0

我正在尝试获取一个自定义单页来吐出帖子的标题和内容,标题效果很好,帖子的内容似乎不想通过。我在wordpress中工作不多,所以我在这里一无所知,有人可以告诉我如何解决这个问题吗?这是我的 single-news.php 代码:

<?php get_header(); ?>
<div class="decade1">
<?php

echo get_the_title().'<br/>'; //Output titles of queried posts
echo get_the_content().'<br/>';

?>
</div>
<?php get_footer(); ?>

谢谢!!

4

2 回答 2

0

get_the_content()必须在循环中使用。

句法:

get_the_content( $more_link_text, $stripteaser )

where$more_link_text$stripteaser是可选的。 阅读它

并且get_the_title()只有在循环中才会输出标题,否则您必须提供帖子ID才能显示标题。

get_the_title($post_id)
于 2014-02-25T05:49:45.250 回答
0

在使用诸如get_the_title().

<?php get_header(); ?>
<div class="decade1">
  <?php
  if ( have_posts() ) {
    while ( have_posts() ) {
      the_post();
      echo get_the_title() . '<br/>'; 
      echo get_the_content() . '<br/>';
    } // end while
  } // end if
  ?>
</div>
<?php get_footer(); ?>
于 2014-02-25T05:39:14.903 回答