2012-11-22 112 views
0

我有一個WordPress模板頁面,其中顯示頁眉,頁腳和側邊欄,但內容沒有顯示任何人都可以幫助?WordPress的the_content不工作頁面模板

<?php 
/** 
* Template Name: Template 2 
*/ 
?> 

<?php get_header(); ?> 

<div class="main_right" style="float:right;"> 
    <?php get_sidebar(1); ?>       
</div> 
<div style="float:left">  

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<?php echo the_content();?> 

<?php endwhile; endif; ?> 
</div> 

<?php get_footer(); ?> 
+0

我不認爲你需要「回聲」 - the_content()自動迴應內容。如果你刪除它,它會工作嗎? – Hobo

+0

我也嘗試刪除回聲,但沒有效果 –

+0

hmm;除此之外,它看起來不錯。你的網頁是否有內容?如果切換到另一個模板,它會出現嗎? – Hobo

回答

2

這是否在你的wordpress循環中?它必須是爲了讓the_content工作。

而且,你不需要爲了呼應功能,只需把它放在你的文件是這樣的...

<?php the_content(); ?> 

而且,爲什麼你要來包裝內容<p>標籤? Wordpress會自動爲你做這件事。如果你想包裝它<div>會好得多,可能有一個類或ID爲CSS使用。

你有沒有看過wordpress codex? - http://codex.wordpress.org/Function_Reference/the_content