在使用WordPress里在一個頁面里我使用the_content()方法來輸出當前頁面的內容,但卻顯示為空,而標題,url等都沒有問題
在網絡上好像遇到這種情況的人很少只找到了一個說是可能是function里有函數覆蓋了the_content方法
但我將function方法刪除掉還是不行,然后我將代碼全部刪除掉只留這一句"<?php the_content()?>"
結果還是不行,無奈只能通過其他方式解決
解決方案:
使用$post對像里的屬性“ <?php echo $post->post_content;?>”
下面是我的page.php里的所有內容
<?php /** 內頁/單頁面 * @author htl * @date 2014-01-28 */ get_header(); ?> <?php get_sidebar()?> <div id="neirong"> <?php if ( have_posts() ) :?> <h1><?php the_title();?></h1> <div id="content"> <?php the_content()方法無法輸出文章內容,通過$post對象里的post_content屬性來輸出 //the_content(); //print_r($post); echo $post->post_content;?> </div> <?php else : ?> <?php get_template_part( '404'); ?> <?php endif; ?> </div> <!-- neirong end --> <?php get_footer(); ?>