2
votes

Hello i'm completely new to wordpress and i'm trying to create my own custom theme for a website, i understand some of what i have done but i must admit that some stuff still looks weird to me. The porblem i'm having right now is that when i add a new page and i add content to that page the content doesn't show up when i visit the site but the header and footer display fine, i have checked the source code and have noticed that the content doesn't get generated.

These are my code files for my custome themefile:

[Header.php]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
        <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/menu.css" type="text/css" />
        <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    </head>
    <body>
        <div id="header">
            <div class="content">
                <div id="logo-with-contact">
                    <img src="<?php bloginfo('template_url') ?>/images/Amissah, Amissah - Logo.png" alt="Amissah, Amissah & Co" id="header-image" />
                    <div class="clear"></div>
                </div>
            </div>
            <nav id="top-menu-nav">
                <ul>
                    <li><a href="<?php echo get_option('home') ?>">Home</a></li>
                    <?php echo wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
                </ul>
            </nav>
        </div>
        <div class="clear"></div>

[Footer.php]

<div id="footer">
    <div class="content">
      <div class="block" style="margin-left: 0px">
        <h3>Quick Links</h3>
        <br />
        <ul>
          <li><a href="our-firm.html">Our Firm</a></li>
          <li><a href="our-practices.html">Our Practices</a></li>
          <li><a href="resources.html">Resources</a></li>
        </ul>
      </div>
      <div class="block">
        <h3>About Us</h3>
        <br />
        <ul>
          <!--<li><a href="corporate-info.html">Corporate Info</a></li>-->
          <li><a href="staff.html">Staff</a></li>
          <li><a href="testimonials.html">Testimonials</a></li>
        </ul>
      </div>
      <div class="block">
        <h3>Stay Connected</h3>
        <br />
        <ul>
          <li><a href="#" title="facebook"><img src="<?php bloginfo('template_url') ?>/images/facebook-icon.png" alt="facebook" />&nbsp;Join us on facebook</a></li>
          <li><a href="#" title="twitter"><img src="<?php bloginfo('template_url') ?>/images/twitter-icon.png" alt="twitter" />&nbsp;Follow us on twitter</a></li>
          <li><a href="https://login.secureserver.net/index.php?app=wbe" title="mail"><img src="<?php bloginfo('template_url') ?>/images/E-Mail.png" alt="staff mail" />&nbsp;Staff Email</a></li>
        </ul>
      </div>
      <div class="block" style="width:220px; line-height: 18px;">
        <h3>Contact Us</h3>
        <br />
        Email: [email protected]<br />
        Location: xxxxx-xxxxx Memorial Court,<br />
        F xxx/5, xth xxxxx Street,<br />
        xxxx xxxx Avenue, xxxx,<br />
        Adjacent the xxxx xxxxxx Embassy,<br />
        Accra<br />
        Telephone: xxxx xxx xxx </div>
      <div class="clear"><br /><br /></div>
      <div class="horizontal-divider"></div>
    </div>
</div>
    </body>
</html

[Index.php]

<?php get_header(); ?>

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

    </div>
</div>

<?php get_footer(); ?>
3

3 Answers

2
votes

Looks like you are missing the loop, this is what wordpress uses to loop through any posts/pages passed to the template and present the content.

Try adding this to your index.php in your content div

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

    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>

    <?php endwhile; ?>
<?php endif; ?>

You can read all about it here - http://codex.wordpress.org/The_Loop

0
votes

As Per WordPress,

The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The Loop tags. Any HTML or PHP code in the Loop will be processed on each post.

Can be found here, http://codex.wordpress.org/The_Loop

<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
        //
        // Post Content here the_content();
        //
    } // end while
} // end if
?>

Basically, "the loop" is the dynamic portion of WordPress that spits out page, post, and other content.

0
votes

Place The Following COde In index.php after

<div id="primary" class="site-content">
    <div id="content" role="main">
    <?php if ( have_posts() ) : ?>

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>

        <?php twentytwelve_content_nav( 'nav-below' ); ?>

    <?php else : ?>

        <article id="post-0" class="post no-results not-found">

        <?php if ( current_user_can( 'edit_posts' ) ) :
            // Show a different message to a logged-in user who can add posts.
        ?>
            <header class="entry-header">
                <h1 class="entry-title"><?php _e( 'No posts to display', 'twentytwelve' ); ?></h1>
            </header>

            <div class="entry-content">
                <p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'twentytwelve' ), admin_url( 'post-new.php' ) ); ?></p>
            </div><!-- .entry-content -->

        <?php else :
            // Show the default message to everyone else.
        ?>
            <header class="entry-header">
                <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
            </header>

            <div class="entry-content">
                <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
                <?php get_search_form(); ?>
            </div><!-- .entry-content -->
        <?php endif; // end current_user_can() check ?>

        </article><!-- #post-0 -->

    <?php endif; // end have_posts() check ?>

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