Offset all post by one.

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

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  braddalton 2 weeks, 4 days ago.

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

    jourdain
    Member
    Post count: 49

    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 4 months, 2 weeks ago by  jourdain.
    • This topic was modified 4 months, 2 weeks ago by  jourdain.
    http://creativefreaks.co.uk/
    #107990

    jourdain
    Member
    Post count: 49

    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' );
        }
    }
    #126650

    braddalton
    Participant
    Post count: 10182
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.