Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter colinacronin

    (@colinacronin)

    You wouldn’t need to edit multiple footers. You would call the footer the same way in each of those 12 files as you mention. If you want to edit the footer you just edit the footer.php file.

    Thread Starter colinacronin

    (@colinacronin)

    Perhaps this will help illustrate. Here are two examples of a WordPress index.php file. The first is how it would look by default

    <?php
    /**
    * The main template file
    *
    * This is the most generic template file in a WordPress theme
    * and one of the two required files for a theme (the other being style.css).
    * It is used to display a page when nothing more specific matches a query.
    * For example, it puts together the home page when no home.php file exists.
    *
    * @link http://codex.wordpress.org/Template_Hierarchy
    *
    * @package WordPress
    * @subpackage Twenty_Twelve
    * @since Twenty Twelve 1.0
    */
    
    get_header(); ?>
    
    	<div id="primary" class="site-content">
    		<div id="content" role="main">
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    This second version is how I would write it.

    <?php
    /**
    * The main template file
    *
    * This is the most generic template file in a WordPress theme and one
    * of the two required files for a theme (the other being style.css).
    * It is used to display a page when nothing more specific matches a query,
    * e.g., it puts together the home page when no home.php file exists.
    *
    * @link http://codex.wordpress.org/Template_Hierarchy
    *
    * @package WordPress_Themes
    * @subpackage Custom_Theme
    */
    ?>
    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    
    	<?php get_template_part( 'head', 'index' ); /* Includes <head> info, wp_head(), etc */ ?>
    
    	<body <?php body_class(); ?>>
    
    		<?php get_header(); ?>
    
    		<div id="primary" class="site-content">
    
    		</div>
    
    		<?php get_footer(); ?>
    
    	</body>
    
    </html>

    This seems to make more sense to me, because you can see how the entire webpage is put together. You have the opening html tag, a call for the head section, the opening body tag, the body content, a call for the footer, the closing body tag, and the closing html tag. All of this is in one file so it is easy to understand.

    Is there some function of WordPress that my way misses? I have tried it on a test site and everything seems to be running properly. But this is different than the official WordPress documentation, so I want to make sure I’m not missing something crucial.

    Thread Starter colinacronin

    (@colinacronin)

    Yes I have. Do the existence of those other files make a difference? Wouldn’t you just construct each of them in the same manner? In most cases I would assume you would just modify the content between the body tags for such pages as the post/page, category, etc. And if you wanted to do something more with the header or footer you would either modify that for those pages, or have some kind of conditional PHP that changes those sections automatically.

    Thread Starter colinacronin

    (@colinacronin)

    I ended up just changing the font color. But if anyone has ideas for what I was missing (why the link color stayed default gray) I would love to hear them.

Viewing 4 replies - 1 through 4 (of 4 total)