Offset posts loop in order not to repeat posts in the slider

Posted in: Newspaper
Post count: 21

I want to start the posts loop with some offset so that the posts in the slider are not repeated in the article list.

I can do this for the Template “Homepage – with article list” using the following code:

Inside page-homepage-loop.php

$queryPost = Array(
    'posts_per_page' => get_option('posts_per_page'),
    'paged' => $paged
);

Add the following element to the array:

'offset' => 5,

But I cannot do this with Template “Homepage – blank”.

The template php file page-homepage-blank.php does not have query_posts() call. What should I do in order to offset the post listing?

Post count: 21

I found a solution. Here is it:

Edit Newspaper/includes/app/shortcodes/td_block_3.php:

        $td_query = &$td_data_source->get_wp_query($atts); //by ref  do the query

Add the following line before it:

        $atts['offset'] = 5;
        $td_query = &$td_data_source->get_wp_query($atts); //by ref  do the query

Edit Newspaper/includes/content_builder/td_data_source.php

        extract(shortcode_atts(
                array(
                    'category_ids' => '',
                    'tag_slug' => '',
...             ),
                $atts

Add the following element to the above array:

                    'offset' => 0,

And add the following line after $args created:

$args['offset'] = $offset;

Post count: 3343

Hello,
Great! I’m glad you solve it.

Thanks.

Post count: 13

mertnuhoglu thanks for the solution but…

[1]
inside “page-homepage-loop.php” no code:

$queryPost = Array(
    'posts_per_page' => get_option('posts_per_page'),
    'paged' => $paged
);

What code and where exactly to put this to work?

[2]
I’m using Template “Homepage – blank” and visual compser use ‘block 2’
and changed analogously:
1. I edit Newspaper/includes/app/shortcodes/td_block_2.php:
2. Where in the file ‘Newspaper/includes/content_builder/td_data_source.php’ insert the offset?
Such as?

        extract(shortcode_atts(
                array(
					'offset' => 0,
                    'category_ids' => '',
                    'tag_slug' => '',
...             ),
                $atts

3. Where exactly (line number) to put this
$args['offset'] = $offset;

Please help?

Post count: 21
Post count: 13

Thank you for the quick reply.
Unfortunately, this is not a complete solution, because pagination is not working properly.

Eg.
When I change the file page-homepage-loop.php.
If I 7 post and set the display of 6 post per page and I set offset = 5 page displays two posts and display the pagination.

Do you know how to improve the pagination pages?

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.