Support » Fixing WordPress » static front page with separate blog page

  • Hi there,

    I have found many entries for this issue, but not quite like mine!

    I have set the reading settings to a ‘welcome!’ static front page I created and the posts page to ‘Blog’ which is a page I created and also added to my main menu. When I click on ‘Blog’ I only see the last post that was submitted, not all of them.

    Site in maintenance for now (and a collaboration, so can’t reveal) but any ideas why only one post shows? If I click on the ‘uncategorized’ (which they all are) I see all 3 posts. I know I can fix this with categories, but as others less savvy will be using the site, I would rather this worked properly.

    Thanks 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • Try switching to the default theme and see if the problem persists. If not, this is a problem with your theme.

    In any case, to resolve it you can add this to your functions.php file:

    function blog_post_count_06172013( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'posts_per_page', '10' );
        }
    }
    add_action( 'pre_get_posts', 'blog_post_count_06172013' );
    Thread Starter rachellucie

    (@rachellucie)

    thanks 🙂

    I went back to a default, and hey presto, fixed, so I’m guessing it’s the theme which is Ascetica.

    for the above code, should I add it to the main theme functions.php or create one with just this and add it to the child theme?

    You should add it to your child theme functions.php. That is always the best practice.

    Also, it should be noted that this fix is a bit of a hack. Better to diagnose and resolve the root cause of the problem if you can.

    Thread Starter rachellucie

    (@rachellucie)

    right, thanks.

    Is all the code required for the child functions.php in that snippet you gave me? When I added it to the child theme, the code just displayed in a line across the top of the page. When I tried to add it to the main functions.php it totally broke my site! I have now fixed it, but there was still a problem with it as a child.

    Any ideas on that?

    thanks 🙂

    You need an opening PHP tag before the code, if your functions.php file is otherwise empty.

    It should look like this:

    <?php
    function blog_post_count_06172013( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'posts_per_page', '10' );
        }
    }
    add_action( 'pre_get_posts', 'blog_post_count_06172013' );
    Thread Starter rachellucie

    (@rachellucie)

    I added exactly that via ftp to a blank php file, and it places this line of script along the top of my page!

    <?php function blog_post_count_06172013( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, ’10’ ); } } add_action( ‘pre_get_posts’, ‘blog_post_count_06172013’ );

    (it was a file I called functions.php and inserted into the child theme)

    That is bizarre. What program are you using to create your functions.php file? Try using Notepad or another plain text editor.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘static front page with separate blog page’ is closed to new replies.