Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [offsets]

The tag has no usage guidance.

1
vote
1answer
406 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
0answers
34 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
1answer
47 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
0answers
22 views

WordPress | WP_Query | The post 'offset' is not working and posts_per_page is not set to -1 [duplicate]

Why is my random post query ignoring the offset value? <!-- RECENT BLOG POSTS --> <?php $recentargs = array( 'post_type' => 'post', 'post_status' => 'publish', '...
0
votes
1answer
557 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
0answers
18 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
1answer
30 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
23 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
0answers
20 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 ...
1
vote
1answer
310 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
484 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() ...
0
votes
2answers
523 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
235 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
85 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
4answers
1k 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
0answers
387 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 ...
0
votes
1answer
31 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
2answers
17k 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 ...
0
votes
1answer
31 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
1answer
31 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
1answer
147 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
1answer
379 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?
1
vote
1answer
9k 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, ) ); ...
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. ...
1
vote
1answer
2k 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 ...
8
votes
2answers
1k 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
3k 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 ...
1
vote
1answer
891 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
1answer
4k 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
2answers
1k 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
0answers
957 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? ...
0
votes
1answer
433 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
1answer
308 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 "...
1
vote
2answers
4k 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 > <...
2
votes
2answers
475 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....
0
votes
2answers
109 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 ...
1
vote
2answers
204 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 ...
0
votes
2answers
4k 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
2answers
1k 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 ...
3
votes
2answers
2k 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
1answer
247 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
487 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
1answer
123 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
1answer
483 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://...
1
vote
1answer
639 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 ...
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 ...
0
votes
2answers
270 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
755 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 ...
1
vote
1answer
449 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 ...