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?
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;
-
This reply was modified 12 years by
mertnuhoglu.
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?
Hi,
You can find the files here:
http://dl.dropbox.com/u/103580364/temp/forum/page-homepage-loop.php
http://dl.dropbox.com/u/103580364/temp/forum/td_block_3.php
http://dl.dropbox.com/u/103580364/temp/forum/td_data_source.php
There you can see the exact locations to make the changes.
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?
