Offset all post by one.

Community Forums Forums Design Tips and Tricks Offset all post by one.

This topic is: not resolved

This topic contains 1 reply, has 1 voice, and was last updated by  jourdain 3 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #107916

    jourdain
    Member
    Post count: 46

    Hi there, I would like to offset all my posts by 1 on all category pages and the homepage. I have added a featured widget on all category pages so at the moment each post is displayed twice. This is best seen on my site .

    I did manage to do this using a tutorial I found on-line, however, it also affected the WordPress back-end. I could not see the latest post.

    Any help or pointers on this would be much appriciated.

    Thanks in advance. :)

    Jourdain

    • This topic was modified 3 months, 2 weeks ago by  jourdain.
    • This topic was modified 3 months, 2 weeks ago by  jourdain.
    http://creativefreaks.co.uk/
    #107990

    jourdain
    Member
    Post count: 46

    If any one is interested I sorted this problem with the following code

    //Offset bolg by 1 post
    add_action( 'pre_get_posts','child_change_home_query' );
    function child_change_home_query( $query ) {
        if ( $query->is_main_query() and is_front_page() || is_archive() ) {
            $query->set( 'posts_per_page', '10' );
            $query->set( 'offset', '1' );
        }
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.