下面由WordPress教程欄目給大家介紹wordpress教程 無法使用the_content()方法輸出內容的解決辦法,希望對需要的朋友有所幫助!
在使用WordPress里在一個頁面里我使用the_content()方法來輸出當前頁面的內容,但卻顯示為空,而標題,url等都沒有問題
在網絡上好像遇到這種情況的人很少只找到了一個說是可能是function里有函數覆蓋了the_content方法
但我將function方法刪除掉還是不行,然后我將代碼全部刪除掉只留這一句”“
結果還是不行,無奈只能通過其他方式解決
解決方案:
使用$post對像里的屬性“?post_content;?>”
下面是我的page.php里的所有內容
<?php /** 內頁/單頁面 * @author htl * @date 2014-01-28 */ get_header(); ?><?php get_sidebar()?><div> ??<?php if ( have_posts() ) :?> ????<h1><?php the_title();?></h1> ????<div>??????? ??????<?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(); ?>
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END