Support

Account

Home Forums Add-ons Repeater Field Repeater field empty Reply To: Repeater field empty

  • I’ve found the problem. In my theme if got an offset. And that conflicted with the repeater field.

    This is the offset I used. I made an adjustment to is so it only works on the index.

    /* offset the default wordpress loop with 3 items */
    add_action('pre_get_posts', 'myprefix_query_offset', 1 );
    function myprefix_query_offset(&$query) {
    
        if ( !$query->is_home() ) {
    	    $offset = 3;
    	    $ppp = get_option('posts_per_page');
    	
    	    if ( $query->is_paged ) {
    	        $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );
    	        $query->set('offset', $page_offset );
    	    }
    	    else {
    	        $query->set('offset',$offset);
    	    }
        }
    
    add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
    function myprefix_adjust_offset_pagination($found_posts, $query) {
    
        //Define our offset again...
        $offset = 3;
    
        //Ensure we're modifying the right query object...
        if ( $query->is_home() ) {
            //Reduce WordPress's found_posts count by the offset... 
            return $found_posts - $offset;
        }
        return $found_posts;
    }