Questions tagged [offsets]
The offsets tag has no usage guidance.
63
questions
0
votes
1
answer
27
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 ...
1
vote
1
answer
57
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 ...
0
votes
0
answers
12
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
0
answers
239
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
2
answers
851
views
Pagination Not Working When Used With WP_Query() `offset` Property
I have an archive page that pulls in posts using WP_Query(). On the homepage of the site it shows 16 of the custom post type posts, so on the archive I offset the archive page by 16 posts.
The code ...
0
votes
2
answers
60
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
1
answer
252
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 ...
1
vote
1
answer
4k
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
0
answers
438
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 ...
0
votes
1
answer
889
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
0
answers
29
views
Timezone for Plugin
I'm using these two lines:
$expires = strtotime( $_POST['expire_date']);
if($expires < time())
to test the time in the name=expire_date form against GMT time. But no matter what I do my expire ...
0
votes
1
answer
104
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
1
answer
213
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
0
answers
40
views
Best practice and technology to Offset anchor links
I am using anchor links in the Front Page of this Website.
They are in ACCUEIL, SPORTIVES, VOYAGES and CONTACT.
In order for the anchor links to land in the right place, below the menu upper bar, is ...
0
votes
2
answers
3k
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 ...
1
vote
1
answer
2k
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, ...
0
votes
2
answers
382
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
1
answer
459
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
0
answers
751
views
Jquery scroll animate offset asynchronous
I am a beginner in Jquery and I am trying to scroll an element in my page but I can't stop it properly when reaching the footer. It worked if I smoothly scroll down but in other case it's going down ...
1
vote
1
answer
2k
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.
...
0
votes
1
answer
45
views
myprefix_adjust_offset_pagination' not found
I have excluded the first 5 posts from the first page on the main page
This is the only code that works for me in my functions.php:
function my_function_for_excluding_posts( $query ) {
if ($query->...
1
vote
5
answers
37k
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
votes
2
answers
1k
views
Style first 3 posts differently and use a 2nd loop to get rest of posts / offset and pagination broken
I'm working on a theme and I am having trouble with loops/pagination breaks when using an offest. I looked online and tried to use only 1 loop (per this post) but I'm having trouble making it work.
I ...
0
votes
1
answer
36
views
Using something else instead of using 9 wp_query
Hi I'm using these 9 wp_query in index.php
I want to know that is there any another way to do the same thing but without using lot of queries?
<?php $bigindex = new WP_Query('posts_per_page=1&...
0
votes
1
answer
92
views
Undefined offset: 1
I get an Undefined offset: 1 message from this query below.
Do not understand why I get it. The echo results in correct data.
echo $url_slug ;
$Exploded_slug = explode($user->ID.'--',$url_slug);
...
0
votes
1
answer
223
views
Featured Image as Background with Offset
I have a custom Wp_Query in my header that displays the latest post and then a list of 10 posts below which are offset so not to include the recent post.
I want to use the latest post's featured ...
-2
votes
1
answer
823
views
How to remove post duplicate when using query_posts('offset=1')
I used query_posts('offset=3') in index.php, while there exist a problem in pagination. In all page it show the same content of first page.
How to solve this problem?
10
votes
1
answer
32k
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,
) );
...
1
vote
1
answer
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
1
answer
1k
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() ...
9
votes
2
answers
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....
0
votes
1
answer
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 ...
2
votes
2
answers
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 ...
0
votes
0
answers
1k
views
Wordpress WP_Query offset parameter not working with search parameter
On a wordpress query every time i add the 's' parameter the 'offset' and 'posts_per_page' will not work, it will query all posts by using the 's' parameter only, why is that? am I missing something?
...
1
vote
1
answer
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 ...
0
votes
1
answer
622
views
Offset loop not showing the last post
I can get all my posts in the following loop to show except the last? There should be ten posts but it's only showing nine?
<div class="row staff-board">
<?php $...
0
votes
1
answer
507
views
Querying Multiple Categories With Different Offsets
On my website I have a "Breaking News" section which shows the most recent 4 stories in the "Breaking News" Category.
Under this I have a featured news section which displays 5 more stories from the "...
0
votes
2
answers
154
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
4
answers
3k
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 ...
1
vote
2
answers
421
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 ...
6
votes
2
answers
6k
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 ...
0
votes
2
answers
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
1
answer
3k
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
2
answers
6k
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;
...
1
vote
2
answers
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 >
<...
0
votes
1
answer
278
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
1
answer
521
views
wordpress category.php query for featured news item, broken pagination and repeating posts
I am having a few issues with a site I am building, on the news page It has 1 featured post from the news category and then under that more news category posts, but missing out the featured news item ...
0
votes
1
answer
126
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 ...
3
votes
2
answers
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,
'...
0
votes
1
answer
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: ...