2017-01-03 49 views
0

我正在爲我的網站開發一個自定義的WordPress主題,我遇到了一個障礙。我有一個新聞頁面,我已經設置了顯示帖子。帖子在新聞頁面上正確顯示,但是當我點擊帖子本身的鏈接時,帖子完全變成空白。它將我帶到正確的URL,但帖子的頁面是完全白色的。我已經嘗試切換到另一個主題,它顯示得很好,我似乎無法找到任何其他人在線有這個問題,所以我敢肯定,這是我與我的主題做一些真正的noobish錯誤。WordPress的 - 看不到個人職位

我正在使用的代碼是非常基本的(這是目前的index.php):

<div id="content" class="content_field"> 

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

     <div id="news_title"> 
      <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
     </div> 

     <div id="news_body"> 
      <?php the_content(); ?> 
     </div> 

    <?php endwhile; ?> 

</div> 
+1

有沒有single.php? –

+0

請使用single.php在您的主題中創建一個文件,並將相同的代碼放在 – Coder

+0

以上,這是問題所在。非常感謝,我仍然是一個WordPress的初學者,所以noobie問題是一個痛苦! – ZackAkai

回答

0

爲此,你必須在你的主題文件夾中創建一個文件single.php和粘貼代碼。

<div id="content" class="content_field"> 
<?php while (have_posts()): the_post(); ?> 
    <div id="news_title"> 
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
    </div> 
    <div id="news_body"> 
     <?php the_content(); ?> 
    </div> 
<?php endwhile; ?> 
</div> 
0
<?php 
/** 
* The Template for displaying all single posts 
* 
* @package WordPress 
* @subpackage Twenty_Twelve 
* @since Twenty Twelve 1.0 
*/ 
get_header(); ?> 

    <div id="primary" class="site-content"> 
     <div id="content" role="main"> 

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

       <div id="news_title"> 
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
       </div> 

       <div id="news_body"> 
        <?php the_content(); ?> 
       </div> 

       <nav class="nav-single"> 
        <h3 class="assistive-text"><?php _e('Post navigation', 'twentytwelve'); ?></h3> 
        <span class="nav-previous"><?php previous_post_link('%link', '<span class="meta-nav">' . _x('&larr;', 'Previous post link', 'twentytwelve') . '</span> %title'); ?></span> 
        <span class="nav-next"><?php next_post_link('%link', '%title <span class="meta-nav">' . _x('&rarr;', 'Next post link', 'twentytwelve') . '</span>'); ?></span> 
       </nav><!-- .nav-single --> 

       <?php comments_template('', true); ?> 

      <?php endwhile; // end of the loop. ?> 

     </div><!-- #content --> 
    </div><!-- #primary --> 

<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

請您創建single.php文件在您的活動主題的根目錄。並複製並粘貼上面的代碼。

我希望它適合你。

0

爲了顯示個人後,你需要在你的主題

在single.php中把下面的代碼創建的single.php文件:

<div id="primary" class="content-area"> 
<?php while (have_posts()) : the_post(); ?> 
<header class="entry-header"> 
    <?php the_title('<h1 class="entry-title">', '</h1>'); ?> 
</header> 
<div class="entry-content"> 
<?php the_content(); ?> 
</div> 
<?php endwhile; ?> 

去,雖然WordPress Template Hierarchy讓你」我會對文件結構有更多的瞭解。