Offsets

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  Robin 1 year, 6 months ago.

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

    Robin
    Participant
    Post count: 42

    On this thread – http://www.studiopress.com/forums/topic/home-php-not-working/

    I got my home.php to work by adding code to the functions.php

    Forgot to ask about offsets.  I tried this code below for offsets but it didn’t work.  Can you tell me what I am doing wrong.

    This is the website – http://ohsweetbasil.com

    add_action(

    ‘pre_get_posts’,‘child_change_home_query’ );
    function child_change_home_query( $query ) {
    if( $query->is_main_query() && $query->is_home() ) {
    $query->set( ‘posts_per_page’,’6′,’offset’,’5′ );
    }
    }

    Thanks,

    Robin

    • This topic was modified 1 year, 6 months ago by  Robin.
    • This topic was modified 1 year, 6 months ago by  Robin.
    • This topic was modified 1 year, 6 months ago by  Robin.
    • This topic was modified 1 year, 6 months ago by  Robin.
    #21130

    Peter
    Participant
    Post count: 76

    I’m just guessing here Robin, but have you tried splitting the two query changes like this;

    [php]add_action( ‘pre_get_posts’,’child_change_home_query’ );
    function child_change_home_query( $query ) {
    if ( $query->is_main_query() AND $query->is_home() ) {
    $query->set( ‘posts_per_page’, ’6′ );
    $query->set( ‘offset’, ’5′ );
    }
    }[/php]

    Forum did something weird with the ampersands so I used “AND” instead..


    Website: petercoughlin.com
    Twitter: petercoughlin

    #22530

    Robin
    Participant
    Post count: 42

    Sorry just now saw your response. Kept checking back and wasn’t getting any answers and just now got back to it.

     

    Yayyyyyyyyyyyyyyyyyyyy — your suggestion works

     

    thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.