Questions tagged [offsets]
The offsets tag has no usage guidance.
64
questions
9
votes
2answers
2k views
How can I create a category landing page followed by pages of posts?
I'm trying to create a category template in my theme that will display static content if the user is on the first page of the archive, and then display the posts in the category on the following pages....
6
votes
2answers
4k views
Different 'posts_per_page' setting for first, and rest of the paginated pages?
How do you set the posts_per_page query setting so that a different number of posts are displayed on the first of the paginated pages (of home, archive, search, etc.) and the rest of them?
For ...
5
votes
1answer
21k views
WP_Query offset argument does not work
I want to display all posts starting from a certain offset, my query is:
WP_Query( array(
'posts_per_page' => -1,
'offset' => 20,
'cat' => 5,
) );
...
3
votes
2answers
3k views
Using Offset in Custom Post Type Query
I'm using the following query for a custom post type:
<?php
$posts = get_posts(array(
'numberposts' => -1,
'offset' => 20,
'...
2
votes
2answers
2k views
Exclude first 5 posts of specific categories in the main loop
I read this article about how to set an offset for one specific category in the loop. I was wondering about if this was possible for more than just one category.
My problem with the code suggested in ...
2
votes
1answer
4k views
Custom query, works, but I get a “Notice: Undefined offset: 0…”
My custom query works, but in debugging mode I get this error:
Notice: Undefined offset: 0 in /storage/content/24/150624/mydomain.com/public_html/wp/mysite/wp-includes/query.php on line 2232
This ...
2
votes
2answers
495 views
Most commented / popular posts and offset
I am using this code to show 3 most popular posts based on number of comments :
<?php
$pop_posts = 3;
$popularposts = "SELECT $wpdb->posts.ID, $wpdb->posts....
1
vote
1answer
4k views
WP_Query: offset ignored when posts_per_page is -1?
Is it only me or this is what's happening?
I just want to get all posts starting from a certain offset, like 10. Instead I get all posts starting from the 0.
1
vote
1answer
3k views
Two custom loops, pagination, offset
I have two Loops using WP_Query.
The first loop shows X posts. No pagination.
(loop A)
The second loop shows Y posts. With custom pagination.
(loop B)
It kinda works; but you can see the second ...
1
vote
1answer
884 views
Offset Page Loops and Pagination
I have really been struggling with getting the main loop for the index.php to work properly with WP_Query functions. I need the grid array of 6 featured images at the top to not be offset at all, ...
1
vote
1answer
954 views
How select a specific query when setting offset?
In wordpress I added a function which sets the offset like so:
add_action('pre_get_posts', 'myprefix_query_offset', 1 );
function myprefix_query_offset(&$query) {
if ( ! $query->is_home() ...
1
vote
1answer
967 views
How to use offset in WP_Query
Where do I put the offset function?
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'category',
'orderby' =&...
1
vote
1answer
1k views
WP Query with offset breaks wp_pagenavi or any pagination
I am working on a custom loop using WP_Query using the offset parameter. The problem is that as soon as I add the offset, it breaks the pagination, displaying the same links no matter the page number.
...
1
vote
5answers
32k views
How can I fix: “Notice: Undefined offset: 0”?
I'm Starting a WordPress website and I'm having a problem with some of my posts.
This issue is only affecting 2 out of 4 articles and after investigating I cannot think on a reason for that.
This ...
1
vote
1answer
1k views
WP_Query, pre_get_posts and offset
I can't get my head around, why offset seems to be forwarded from custom WP_Query in page template to the main query further down?!
From my functions.php
/**
* ::: Filter 'Custom Post Type' Archive ...
1
vote
2answers
6k views
Specific Loop For 2 <div> Within Each <li>
I need to create a loop that can logically be described as the following for a carousel:
Requirements:
3 Loops
2 Posts Per Loop
No Duplicates
Order by Post Date
Visual:
< Start Loop #1 >
<...
1
vote
1answer
818 views
Offset a post in the loop, with using PageNavi Plug-in
I am trying to offset 1 post in my main loop, I have tried a few things Like query_posts() etc etc, and i can get the offset to work but my pagination ends up not working , I am using the PagNavi ...
1
vote
1answer
25 views
Missing image in gallery shortcode in custom feed
I have problem with custom gallery shortcode and missing first image in each gallery block. For example: [gallery ids="1,2,3,4,5"] show only 2,3,4,5 pictures.
This custom shortcode is part ...
1
vote
0answers
346 views
Blog page pagination is not working after using the offset argument
I have displayed the recent 7 posts then shown the remaining posts. So I have added the offset = 7 in the argument to skip above 7 recent posts and display remaining posts but the pagination not ...
1
vote
2answers
309 views
Exclude the first 'n' number of posts of a tag from home page?
Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query.
I don't want the ...
1
vote
1answer
556 views
Comments offset
I need to display comments starting from the second, omitting the first.
With posts I did it using "offset" but I can't find anything similar for comments.
Since I'm using threaded comments, must ...
0
votes
1answer
5k views
WP_Query with offset and 'orderby' => 'rand', offset not working
I have the following situation: on my index.php I am showing the most recent 20 posts using WP_Query(). On the same page in another section I would like to display 3 more random posts from the archive ...
0
votes
2answers
5k views
How to adjust found_posts so that it accounts for offset and pagination
So far this is the code I have in my index.php file:
<?php
// Custom code to offset posts and setup pagination
$page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
...
0
votes
1answer
566 views
How do I rewrite this loop as a new WP_Query style-loop?
How do I rewrite the if (have_posts()) : ... while (have_posts()) : the_post(); style Wordpress loop below as a new_query style-loop using <?php $the_query = new WP_Query();? ( As shown in http://...
0
votes
1answer
32 views
WP_Query arguments order
Given the following example of a custom query
$query = new WP_Query(array(
'posts_per_page' => 7,
'categor_name' => 'events',
'offset' => 5
));
Does the order of arguments ...
0
votes
2answers
145 views
Creating two loops based on different logic
I'm trying to figure out the best way to go about this and I have part of my solution, but I can't figure out all of it.
My ultimate goal is within a certain page template, to show the newest post ...
0
votes
4answers
2k views
Get post offset/posts page offset in single post page (outside the loop)
I would like to know how I could get the offset of a custom post or its page, outside the get_posts loop.
I developed an external web application which connects to the wordpress blog with JSON API ...
0
votes
1answer
241 views
Loop Offset for tag based “Related Posts”
As I'm using the jQuery Tool "Scrollable" for my Related Posts section (see example here), I was wondering how I can implement an offset so that in the first loop it'll show the first 4 ...
0
votes
1answer
1k views
WP_Query - Adding “offset” posts to the end of the loop
I'm trying to create two queries.
In the first query, I will, for example, display 6 posts, in a given order.
In the second query, I want to display the same 6 posts, but "offset" the first 3 and ...
0
votes
1answer
1k views
Stomping WP_Query in author archive to facilitate pagination with custom queries
I am using get_posts and get_comments to build several loops on the page, at which I am having some issues in pagination.
I have the global posts per page option (Settings > Reading) set to 10, and ...
0
votes
2answers
33 views
Apply query arguments after the nth post
I can't seem to find an answer/solution to this. If there is one out there, please post a link.
My understanding is that in a wp_query, offset refers to the results of the query. So if I set 'offset' =...
0
votes
1answer
402 views
AJAX Breaking Offset Argument In WP Query
I have been using AJAX on my website successfully and for my category.php page I need to use the offset argument. Unfortunately, AJAX creates complications with offset and I get the same posts looping ...
0
votes
1answer
81 views
Undefined index when saved to options
$options = get_option('analytics');
if ( ! preg_match( '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $options['analytics_startdate'] ) ) {
$options['analytics_startdate'] = '2018-12-01';
}
Why this is ...
0
votes
1answer
75 views
Page navigation doesn't seem to work when I add offset?
I am trying to get a simple navigation to work, it works when I don't use offset in the arguments.
but I like to do something special with the first post
$paged = ( get_query_var('paged') ) ? ...
0
votes
2answers
2k views
WP_Query offset is returning post from prevois loop
On archive pages, I let WordPress handle the archive page and load the first 10 posts, then I load more posts with AJAX requests, and this AJAX request is returning weird results.
My query inside the ...
0
votes
2answers
315 views
Exclude some posts from displaying in wp_query based on some condition
I need some posts excludes from displaying in wp_query in some conditons. I use below code to do it, and the code works correctly, but I set the posts_per_page to 12 and by this code the skiped posts ...
0
votes
1answer
378 views
How to calculate post index when using offset in custom query
Not sure if I'm using the proper terminology in my title so feel free to correct.
Say I have a custom post type called colors with say 40 posts that are in the default order in single_colors.php I ...
0
votes
2answers
2k views
Get the index of post outside the loop
I'm trying to find out the index of the post which is currently viewed (single post page).
I have an overview of the articles in the same category in a sidebar. But when a user navigates to a post ...
0
votes
1answer
2k views
Offset WP_Query by negative 1
I have an event loop and I'm wondering if it's possible to offset the loop by -1, so the prev and next posts of the current post are shown.
EDIT - Thanks for your comments, I think I can clarify. ...
0
votes
1answer
260 views
Offset posts with random order
I'm trying to have five advertisement locations, each pulling posts from the same custom post type, but also loading randomly. The only problem I have with my code below is that it will sometimes ...
0
votes
1answer
124 views
Calling two images at a time? A better way?
I'm having trouble wrapping my head around the best way to achieve this. I'm trying to load two photos at a time into a which serves as a slideshow wrapper. Currently i'm repeating a lot of code and ...
0
votes
1answer
2k views
Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post
I have a loop that I would like to Offset by 1 so the most recent post is not displayed, and another loop where I only want 1 item which would be the most recent post.
These are the loops I tried: ...
0
votes
2answers
276 views
Keeping get_posts' offset and is_paged() synchronized
I am developing the blog-template of my theme, which works as following: The user can input the total post-count to display on each blog-page ($blogpost_count). The blog itself lists post-entries in ...
0
votes
2answers
770 views
Related Posts loop - offset
I've been working on this for many, many, many weeks already. I've already asked similar questions here and elsewhere, but nobody seems to be able to sovle this problem.
Maybe it's not possible ...
0
votes
1answer
608 views
Offset for Loop
I want to have an offset of 4 posts for my related posts. I'm using Flowplayer's jQuery Tools Scrollable, so I want people to be able to scroll through the 4 latest posts, then the next 4 posts etc.
...
0
votes
1answer
453 views
How do I add a timezone offset to this query?
Problem is that $today is pulling GMT from the database; I need to offset GMT by -6 hours; Have been unable to find a query with an offset like that.
<?php
$paged = ( get_query_var('paged') ) ? ...
0
votes
1answer
19 views
Undefined offset: 0 in WordPress after latest version upgrade [closed]
My WordPress powered website always worked great, however after the latest upgrade to 5.6.2 and 5.7 I have a major issue that actually breaks an important part of the website, I have seen to go ...
0
votes
0answers
10 views
Querying Different Categories in Different Loop With Different Offsets
I have four loops. In the first loop I want to display all current articles from all categories (breaking news). In the 2nd loop only articles with the category 4,5,6,7 should be displayed. But if ...
0
votes
0answers
26 views
setting offset to category number in archive page
unit test data added many category to some posts.so, on archive page, the long category list seems bad because you know its long, ugly.
so, to solve this visual problem, I want to set offset to this ...
0
votes
0answers
50 views
Custom posts per page on first page generates wrong number of pagination links
I've looked at every solution I could find, but everything I've tried seem to have this same issue (although nobody has mentioned it).
I have a custom taxonomy with 30 posts in it. Global ppp is 9, ...