Wordpress页脚不显示在常规页面上...仅限主页
问题描述:
Ok, so I'm customizing a wordpress theme and have not been able to understand why the footer widgets are not displaying on regular pages...
Here's the footer.php code:
</div><!--.container_12-->
</div><!--.container-->
</div>
<footer id="footer">
<?php if (is_front_page()) : ?>
<div id="widget-footer">
<div class="container_12 clearfix">
<?php if ( ! dynamic_sidebar( 'Footer' ) ) : ?>
<!--Widgetized Footer-->
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div id="copyright" class="clearfix">
<div class="container_12 clearfix">
<div class="grid_12">
<div id="back-top-wrapper">
<p id="back-top">
<a href="#top"><span></span><span class="hover"></span></a>
</p>
</div>
<div id="footer-text">
<?php $myfooter_text = of_get_option('footer_text'); ?>
<?php if($myfooter_text){?>
<?php echo of_get_option('footer_text'); ?>
<?php } else { ?>
<a href="<?php bloginfo('url'); ?>/" title="<?php bloginfo('description'); ?>" class="site-name"><?php bloginfo('name'); ?></a> <?php _e('is proudly powered by', 'theme1837'); ?> <a href="http://wordpress.org">WordPress</a> <a href="<?php if ( of_get_option('feed_url') != '' ) { echo of_get_option('feed_url'); } else bloginfo('rss2_url'); ?>" rel="nofollow" title="<?php _e('Entries (RSS)', 'theme1837'); ?>"><?php _e('Entries (RSS)', 'theme1837'); ?></a> and <a href="<?php bloginfo('comments_rss2_url'); ?>" rel="nofollow"><?php _e('Comments (RSS)', 'theme1837'); ?></a>
<?php } ?>
<br />
<?php if( is_front_page() ) { ?>
<!-- {%FOOTER_LINK} -->
<?php } ?>
</div>
</div>
</div>
</div><!--.container-->
</footer>
</div><!--#main-->
<?php wp_footer(); ?> <!-- this is used by many Wordpress features and for plugins to work properly -->
<?php if(of_get_option('ga_code')) { ?>
<script type="text/javascript">
<?php echo stripslashes(of_get_option('ga_code')); ?>
</script>
<!-- Show Google Analytics -->
<?php } ?>
</body>
</html>
Here's the homepage code where the footer widgets "are" displaying properly:
<?php
/**
* Template Name: Home Page
*/
get_header(); ?>
<div class="clearfix">
<div class="grid_3">
<div class="left-column">
<?php if ( ! dynamic_sidebar( 'Left Home Area' ) ) : ?><!-- Wigitized Home --><?php endif ?>
</div>
</div>
<div class="grid_9">
<?php if( is_front_page() ) { ?>
<section id="slider-wrapper">
<?php include_once(TEMPLATEPATH . '/slider.php'); ?>
</section><!--#slider-->
<?php } ?>
<div class="row">
<?php if ( ! dynamic_sidebar( 'Right Home Area #1' ) ) : ?><!-- Wigitized Home --><?php endif ?>
</div>
<div class="row-1">
<?php if ( ! dynamic_sidebar( 'Right Home Area #2' ) ) : ?><!-- Wigitized Home --><?php endif ?>
</div>
</div>
</div>
<?php get_footer(); ?>
and here's the normal page code where footer widgets are "NOT" displaying as intended:
<?php get_header(); ?>
<div id="content" class="grid_9 <?php echo of_get_option('blog_sidebar_pos') ?>">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>
<article class="post-holder">
<div class="header-title">
<h1><?php the_title(); ?></h1>
</div>
<?php if(has_post_thumbnail()) {
echo '<a href="'; the_permalink(); echo '">';
echo '<figure class="featured-thumbnail"><span class="img-wrap">'; the_post_thumbnail(); echo '</span></figure>';
echo '</a>';
}
?>
<div id="page-content">
<?php the_content(); ?>
<div class="pagination">
<?php wp_link_pages('before=<div class="pagination">&after=</div>'); ?>
</div><!--.pagination-->
</div><!--#pageContent -->
</article>
</div><!--#post-# .post-->
<?php endwhile; ?>
</div><!--#content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Any ideas?
答
Your footer widgets are included inside an if statement that uses is_front_page()
<?php if (is_front_page()) : ?>
<div id="widget-footer">
<div class="container_12 clearfix">
<?php if ( ! dynamic_sidebar( 'Footer' ) ) : ?>
<!--Widgetized Footer-->
<?php endif; ?>
</div>
</div>
<?php endif; ?>
This will only enter this conditional branch if on the blog index.
If you need to extend this statement, other such checks include is_single()
, is_category()
, is_tax()
, etc.