0

I copied TwentyEleven and used all its resources to start, I've done all the steps, added my own widgets, menus, css, js and all but I'm stuck with this issue:

I set the front page to be static and set a page for it (it has content in it), also set a blank page for the blog posts. The theme just shows the pages as blank for both in all situations unless I specify a wrong file name in which it will show the 'Not found' text.

I'm sure I'm doing something horribly wrong, but what?

Here's the part that loads the content in index.php:

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php get_template_part( 'content', get_post_format() ); ?>

            <?php endwhile; ?>

        <?php else : ?>

            <article id="post-0" class="post no-results not-found">
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
                </header><!-- .entry-header -->

                <div class="entry-content">
                    <p><?php _e( 'Page not found.', 'twentyeleven' ); ?></p>
                </div><!-- .entry-content -->
            </article><!-- #post-0 -->

        <?php endif; ?>
2
  • 1
    Do you see the header and footer part at least? or just a blank screen? Commented Feb 9, 2012 at 6:41
  • Yes, I do. I added the footer and header tags correctly and they work as they should. But no content in the middle. The code doesn't work at all there, doesn't show any blog content or single pages. Just blank in the middle.
    – Ano Madadi
    Commented Feb 9, 2012 at 11:20

1 Answer 1

3

First of all Create Template and Assign Template to Static page to which u have to display as a home page. Example of template:

<?php
/**
* Template Name: Home Page Template
*
*/
get_header();
?>
<div class="mid-part cm-fl">
<div id="container">
<div id="content" role="main">
<div class="left-section">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="body-top"></div>
<div class="entry-content body-content">
<h2 class="entry-title"><?php the_title(); ?></h2>                  
<?php the_content(); ?>                 
</div>
<div class="body-bottom"></div>
</div>

<?php endwhile; ?>
</div>
</div>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
2
  • That did it! You're awesome! Now I only need to correct the styling and it's all good to go. Thanks a ton!
    – Ano Madadi
    Commented Feb 9, 2012 at 11:41
  • First, this shouldn't be necessary, if index.php is present, since it is the default fallback. Second, it's generally a bad idea to conflate the Home page (i.e. the Blog Posts Index) with the Front Page (i.e. the Site Front Page). Third, if you specifically need a site front page template, the correct template to use is front-page.php. No need to add a Template: phpDoc comment, as WordPress will use the template file appropriately, automatically. Commented Feb 9, 2012 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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