2012-10-12 32 views
0

我正試圖學習如何構建自己的WordPress主題。我已經通過了一些教程,但我遇到了一些障礙。我似乎無法弄清楚我做錯了什麼。當我在我的「home.php」相同的文件中有我的我的頁腳的HTML時,它工作正常。當我嘗試分離它,然後將頁腳html放在「footer.php」中並使用「get_footer();」功能,頁腳完全沒有出現,明顯或代碼中......它不在那裏。我想知道是否還有其他一些我忽略做的事來讓頁腳工作?如果不是那麼當我將代碼分成不同的主題部分/文件時,可能會導致頁腳不顯示?WP get_footer函數不顯示頁腳

這裏是home.php代碼:

<?php 
/* 
    Template Name: Front Page 
*/ 
?> 

<?php get_header(); ?> 

<?php get_template_part('nav'); ?> 

<div id="content"><!-- Start Content --> 

    <?php get_sidebar('left'); ?> 

    <div id="middle-column" class="grid_8"><!-- Main Content Begins Here --> 

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?><!-- Start Loop --> 
       <div class="post"> 
        <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2> 
        <div class="entrytext"> 
         <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?> 
        </div> 
       </div> 
       <?php 
      endwhile; 
     else: 
      ?> 
      <?php _e('This page does not appear to have been set up yet. Sorry, please try again later. Thanks!'); ?> 
     <?php endif; ?> 

     <!-- End Loop --> 

    </div> 

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

這裏是footer.php代碼:

<div style="clear:both;"></div> 
    <div id="push"></div> 
</div><!-- End Content --> 
</div><!-- End Container --> 
</div><!-- End Wrapper --> 


<div id="footer"><!-- Start Footer --> 
    <div id="footWrap"><!-- Start #footWrap --> 
     <p>&copy; Brent Blackwood</p> 
    </div><!-- End #footWrap --> 
</div><!-- End Footer --> 

<div id="headerBand"></div><!-- Placed here for SEO purposes --> 
<div id="navBand"></div><!-- Placed here for SEO purposes --> 

</body> 
</html> 

回答

3

我看不出有什麼明顯的錯誤。

你在你的wp-config.php中有define('WP_DEBUG',true);嗎?如果沒有,請添加它並查看是否有可能有幫助的錯誤。

您確定它在get_footer()而不是之前失敗,例如get_sidebar()

你的「首頁」模板文件和footer.php在同一個目錄下嗎?

你有公開的URL嗎?

+0

感謝您的幫助,我仍然遇到了問題,雖然我確實添加了WP_DEBUG並檢查了是否它不是代碼的另一部分。它似乎是get_footer正在打破它。前頁面模板和footer.php位於相同的目錄中。沒有公開的網址,因爲我使用的是MAMP。對不起,但感謝您的幫助。 –

+1

好的。開始尋找[掛鉤到'get_footer']的函數(http://adambrown.info/p/wp_hooks/hook/get_footer)。在add_action('get_footer'或'add_action('get_footer')或者雙引號相同的位置搜索主題和插件的源代碼。 –