0

Can anyone tell me why this wordpress blog is looping the header and banner over and over? It seems like instead of just looping the post it is looping the whole page. This code is inside of my content.php file. Any help would be greatly appreciated.

Here is a link to my blog: http://testing.printlabelandmail.com/blog/

<?php
/**
* The default template for displaying content.
*/
get_header(); ?>

<!-- Start Top Header affix nav-->
<div id="affix" data-spy="affix" data-offset-top="94" data-offset-bottom="0">

<!-- **** START - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** 
<div id="top" class="hide"></div>
<!-- **** END - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->

<!-- **** START - NAV **** -->
<nav class="navbar navbar-default navbar-shrink">
<div class="container">
<div class="navbar-header">
<!-- main-logo goes here-->
<h1 class="brand--font"><a href="<?php echo esc_url( home_url( '/' ) ); ?   >">        PRINTLABELANDMAIL.COM</a></h1>
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-    target=".navbar-ex1-collapse">
      <span class="icon-menu"></span>
    </button>
            </div>
<!-- **** START - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->
<li class="hide"><a href="#top"></a></li>
<!-- **** END - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->
<?php

$defaults = array(
'theme_location'  => '',
'menu'            => 'main-nav',
'container_id'    => 'nav',
'container_class' => 'navbar navbar-default navbar-shrink',
'container'       => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'container_id'    => '',
'menu_class'      => 'menu',
'menu_id'         => '',
'echo'            => true,
'fallback_cb'     => 'wp_page_menu',
'before'          => '',
'after'           => '',
'link_before'     => '',
'link_after'      => '',
'items_wrap'      => '<ul class="nav navbar-nav">%3$s</ul>',
'depth'           => 0,
'walker'          => ''
);

wp_nav_menu( $defaults );

?>
        </div>
    </nav><!-- **** END - NAV **** -->
</div><!-- **** END -affix NAV **** -->
<!-- end Top Header affix nav-->

<!-- **** start blog banner **** -->    
<div id="blog-banner">

<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('blog-banner')) :     else : ?>
<div class="pre-widget">
    <p><strong>Widgetized Area</strong></p>
    <p>This panel is active and ready for you to add some widgets via the WP  Admin</p>
</div>

<?php endif; ?>

</div>
<!-- **** / end blog banner **** -->    

<!-- **** START - BLOG **** -->
<div class="container  blog">
  <div class="row  blog--row">

    <!-- **** START - LEFT CONTENT -->
    <div class="col-lg-8">

      <!-- blog post -->
<!-- blog post -->
<article <?php post_class('box  box--md  blog--post  push--bottom-sml'); ?>>

<?php the_post_thumbnail('thumbnail', array('class' => 'img-responsive push--bottom')); ?>

<h3 class="brand--font-standard"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

<h5 class="brand--font-light"><?php _e('posted by'); ?> <?php  the_author(); ?></h5>

<ul class="list-inline  tags  blog--tags  push--bottom-tiny">             
<li><?php the_category(',') ?></li>
</ul>

<?php the_content('<p class="section-subtitle"><p class="btn  btn--orange  brand-- font">Read More</p></p>'); ?>

<?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?> 

<?php edit_post_link('Edit', ' &#124; ', ''); ?>
</article>

<div class="row">
        <div class="col-lg-12">
          <!-- pagination -->
<ul class="pagination">
            <li class="disabled  pagination--prev"><a href="#">&lt;</a></li>
            <li class="active"><a href="#">1</a></li>
            <li><a href="#">2</a></li>
            <li class="pagination--next"><a href="#">&gt;</a></li>
          </ul><!-- pagination -->
        </div>
      </div>
<ul class="pagination">
<li class="pagination--prev"><?php previous_post_link('<< %link') ?></li> <li     class="pagination--next"><?php next_post_link(' %link >>') ?></li>
          </ul>
</div><!-- **** END - LEFT CONTENT **** -->

<!-- **** START - RIGHT CONTENT **** -->
    <div class="col-lg-4  right-hand-bar">
<?php get_sidebar(); ?>
</div><!-- **** END - RIGHT CONTENT **** -->
</div>
</div><!-- **** END - BLOG **** -->
  • 3
    The function get_header() is used to build the header. See Get Header in the WordPress Codex. Everything Below the Affix Nav needs to go in header.php unless you are using a custom template. If you like I'll Post an answer. Everything in the Footer goes in Footer.php, the only thing in Content.php should be the article, and the sidebar layout goes in sidebar.php – eyoung100 Jun 18 '14 at 15:47
  • Thanks E Carter Young, sometime all you need is someone to say it in a different way! testing.printlabelandmail.com/blog – Kyle Poyser Jun 18 '14 at 16:41
1

custom-header.php

<!-- Start Top Header affix nav-->
<div id="affix" data-spy="affix" data-offset-top="94" data-offset-bottom="0">

<!-- **** START - NAVBAR SCROLLSPY FIX DO NOT REMOVE ****  --> 
<div id="top" class="hide"></div>
<!-- **** END - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->

<!-- **** START - NAV **** -->
<nav class="navbar navbar-default navbar-shrink">
<div class="container">
<div class="navbar-header">
<!-- main-logo goes here-->
<h1 class="brand--font"><a href="<?php echo esc_url( home_url( '/' ) ); ?>">PRINTLABELANDMAIL.COM</a></h1>
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-    target=".navbar-ex1-collapse">
      <span class="icon-menu"></span>
    </button>
            </div>
<!-- **** START - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->
<li class="hide"><a href="#top"></a></li>
<!-- **** END - NAVBAR SCROLLSPY FIX DO NOT REMOVE **** -->
<?php

$defaults = array(
'theme_location'  => '',
'menu'            => 'main-nav',
'container_id'    => 'nav',
'container_class' => 'navbar navbar-default navbar-shrink',
'container'       => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'container_id'    => '',
'menu_class'      => 'menu',
'menu_id'         => '',
'echo'            => true,
'fallback_cb'     => 'wp_page_menu',
'before'          => '',
'after'           => '',
'link_before'     => '',
'link_after'      => '',
'items_wrap'      => '<ul class="nav navbar-nav">%3$s</ul>',
'depth'           => 0,
'walker'          => ''
);

wp_nav_menu( $defaults );

?>
        </div>
    </nav><!-- **** END - NAV **** -->
</div><!-- **** END -affix NAV **** -->
<!-- end Top Header affix nav-->
<!-- **** start blog banner **** -->    
<div id="blog-banner">

<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('blog-banner')) :     else : ?>
<div class="pre-widget">
    <p><strong>Widgetized Area</strong></p>
    <p>This panel is active and ready for you to add some widgets via the WP  Admin</p>
</div>

<?php endif; ?>

</div>
<!-- **** / end blog banner **** -->    

content.php

<?php
/**
* The default template for displaying content.
*/
get_header('custom-header'); ?>
<!-- **** START - BLOG **** -->
<div class="container  blog">
  <div class="row  blog--row">
<!-- **** START - LEFT CONTENT -->
....
<!-- **** END - LEFT CONTENT **** -->
....

I would further recommend putting the sidebars in files named left-sidebar.php and right-sidebar.php, and your footer in custom-footer.php. The aim here is to separate layout from content.

The Ideal layout is:

  • GetHeader
  • GetSidebar(left) - optional
  • Article Content
  • Get Sidebar(right) - optional
  • GetFooter

In that order. So that content.php only contains the article content, and the layout.

Welcome to WordPress.SE. Nice Design BTW...

  1. get_header() Function Reference
  2. get_footer() Function Reference
  3. get_sidebar() Function Reference
  • Thnak you very much! I will certainly be separating "the layout from content" from now on! Kudos for your quick and most clear response! – Kyle Poyser Jun 18 '14 at 16:44
  • @KylePoyser Looks Great, a couple more tips though. To Separate articles, consider using a shortcode that creates a Horizontal Rule, and use the shortcode in the content.php. If this is a custom theme, you'll need to write a shortcode using the Shortcode API, and this Shortcode Generator. Resist the urge to code it using markup, so that you can reuse it elsewhere. See ShortCode Test Page – eyoung100 Jun 18 '14 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.