WordPress.org

Forums

static front page with separate blog page (10 posts)

  1. rachellucie
    Member
    Posted 2 years ago #

    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 :)

  2. Shaun Scovil
    Member
    Posted 2 years ago #

    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' );
  3. rachellucie
    Member
    Posted 2 years ago #

    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?

  4. Shaun Scovil
    Member
    Posted 2 years ago #

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

  5. Shaun Scovil
    Member
    Posted 2 years ago #

    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.

  6. rachellucie
    Member
    Posted 2 years ago #

    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 :)

  7. Shaun Scovil
    Member
    Posted 2 years ago #

    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' );
  8. kmessinger
    Forum Moderator
    Posted 2 years ago #

  9. rachellucie
    Member
    Posted 2 years ago #

    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)

  10. Shaun Scovil
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic