WordPress.org

Ready to get started?Download WordPress

Forums

Blank posts page (14 posts)

  1. tjobbe
    Member
    Posted 2 years ago #

    I have searched lengthily for answers to this and have seen many different potential solutions - none of which work at present.
    ---

    I have a fresh installation of wordpress with a custom theme, have set a specific page for the home page and blog posts page and the blog posts page is coming up as blank, with or without any posts in the database.

    I have tried activating / deactivating plugins, deleting functions.php, removing permalinks etc, but nothign seems to work.

    The page that should show the news articles / blog posts comes up as blank, and no html is generated.

    Any ideas?

  2. tjobbe
    Member
    Posted 2 years ago #

    Getting somewhere, I now have an error message after doing the following in wp-config.php:

    define('WP_DEBUG', true);

    This is what I get: Notice: Constant WP_USE_THEMES already defined in /home/masterep/public_html/wp-dev/wp-content/themes/xxx/index.php on line 14

    Any pointers on this, here's my index.php file from my theme folder:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require('./wp-blog-header.php');
    ?>
  3. keesiemeijer
    moderator
    Posted 2 years ago #

    and no html is generated.

    The page template file probably has a (php) error in it. Does it use a different "Page" template file as the home page?

  4. tjobbe
    Member
    Posted 2 years ago #

    Yes it does, but there's nothing obviously wrong with it to my eyes:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  5. keesiemeijer
    moderator
    Posted 2 years ago #

    here's my index.php file from my theme folder:

    Are you sure this index.php is in your theme folder?

    The contents of this index.php usually is in the root of your website and not a theme template file.

  6. tjobbe
    Member
    Posted 2 years ago #

    Yep, that's the index.php file from my theme folder!

    Right, I have now fixed that file, thanks for pointing out it was the wrong index file. That error message has now gone and I have a page!

  7. keesiemeijer
    moderator
    Posted 2 years ago #

    Strange that it ended up in your theme. Is all now resolved?

    Also, does your theme now have an index.php?

    if not create one of the page template file that shows your blog posts.
    index.php is sometimes used as a fallback template file, so it's better if your theme has one (even if it's not used). see: http://codex.wordpress.org/Template_Hierarchy

  8. tjobbe
    Member
    Posted 2 years ago #

    And now I'm getting no posts displaying, I have created an index.php file. The header and footer are comign through fine, but at the point where my title and excerpt should show up - there's nothing, yet there are two posts in the db, and ive set this same page to be the one displaying the posts?

    I might just be a bit rusty, and I'm missing something obvious?

    This is my news-page.php, which is the template for my news page, which is set in "reading":

    <?php
    /**
     * Template Name: News page
     */
    get_header(); ?>
    
    <div class="all post bottomBorder">
    	<div class="fullWidth">
    
    <?php query_posts(); ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    	<?php the_content(); ?>
    
    	<div class="post">
    		<a class="alignright" href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($id, 'thumbnail'); ?></a>
    		<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    		<?php the_excerpt(); ?>
    	</div>
    
    <?php endwhile; ?>
    
    </div></div>
    <?php get_footer(); ?>
  9. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it without the:
    <?php query_posts(); ?>

  10. tjobbe
    Member
    Posted 2 years ago #

    Hmm, still nothing..

  11. tjobbe
    Member
    Posted 2 years ago #

    This is my news-page.php now:

    <?php
    /**
     * Template Name: News page
     */
    get_header(); ?>
    
    <div class="all post bottomBorder">
    	<div class="fullWidth">
    
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    	<div class="post">
    		<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    		<?php the_excerpt(); ?>
    	</div>
    
    <?php endwhile; ?>
    
    </div></div>
    <?php get_footer(); ?>

    I have set the news page in wordpress to be the page that displays the news, and then i have set the above page as that pages template.

  12. keesiemeijer
    moderator
    Posted 2 years ago #

    just been reading this: http://codex.wordpress.org/Creating_a_Static_Front_Page#Creating_a_Static_Front_Page

    and it says:

    Do not use a custom Page template for this page! home.php or index.php will be used to generate this page.

    So for your blog page index.php or home.php is used to show the news posts

  13. tjobbe
    Member
    Posted 2 years ago #

    Thank you so much for all your help.

    I have done what you said, and it works!

  14. keesiemeijer
    moderator
    Posted 2 years ago #

    No problem. Glad you got it resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic