Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

The loop starting at a certain ID

You can use posts_where hook to achieve this

add_filter( 'posts_where' , 'posts_where' );

function posts_where( $where ) {

    global $wpdb;

    $start = $query->get('ID_VARIABLE_HERE');
    // add any condition if you have
    if ( ! is_admin() && $query->is_main_query()){

        $where .= " AND {$wpdb->posts}.ID >= $start";
    }
    return $where;
}

Related Posts:

  1. Showing random content / pictures from earlier posts in a sticky post?
  2. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  3. Change all author links in Blog roll
  4. How to I retrieve the ID from the Posts page?
  5. Accessing Post ID Within Loop
  6. linking to post outside the loop
  7. Get post category as a separate string and url
  8. Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
  9. View post with specific category id and name which I selected in the backend (drop-down option)
  10. Why does ‘get_the_ID’ work outside of the loop?
  11. wp_query with ajax
  12. Update post meta within save_post action
  13. Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
  14. Display post number by category
  15. Updating post meta for checkbox
  16. Saving Post Data in Another Database
  17. WP_Query: Show 10 posts in date order, first three random
  18. How include css class based on post ( in loop ) slug?
  19. WordPress Loop: How to display recent posts in multiple divs
  20. Querying another post category to match current post and display in loop
  21. How to display posts on custom page without declaring a posts page in reading settings?
  22. Custom permalink for each post
  23. How can I tell if a post has been published at least once?
  24. Show posts by quarter
  25. Is there a way getting post fields using `transition_post_status`
  26. separate the post of a category by subcategory
  27. Automatic blog page with custom design [closed]
  28. How to display post list in a table layout (multiple queries in single loop)
  29. Add multiple meta keys to a post at once
  30. Show number of posts by logged in user
  31. How does WP decide how to display a page
  32. Cannot implement byline into posts container in single.php
  33. Not all posts showing in query
  34. how to handle the loop using filling bootstrap grid structure?
  35. Optimizing the blog loop
  36. How to check if there are posts with the same tag
  37. WP_Query custom field pass the post id
  38. WordPress loop not working on static front page
  39. When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
  40. How do post IDs work in WordPress?
  41. Some doubts about how the loop work (trying debugging it)
  42. Are post, page and category IDs unique to each other?
  43. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  44. Custom WP_Query not working correctly
  45. Different number of posts per row in grid layout
  46. Insert data from custom created PHP page into wp_postmeta table
  47. Optimize CPT-function with a loop
  48. Display specific posts on home page
  49. Adding a meta box to determine the sidebar [closed]
  50. WP_Query of Category Not Showing First Post
  51. If custom field is empty, use one from a previous post
  52. Cant’ Grab WordPress Built-in Posts Through Loop
  53. saving/reading custom field value does not work – no value gets POSTed
  54. Simple Custom Metabox Not Saving
  55. How come this loop is not working? [closed]
  56. Loop not showing first post
  57. Widget to show posts in the sidebar basing on its IDs
  58. Limiting the amount of posts retrieved by the loop
  59. Display 3 posts with different HTML markup using a loop
  60. Get a post’s ID
  61. Making posts permalinks consistent numbers
  62. Pagination for normal (standard) posts on a page with a custom loop?
  63. Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
  64. I can’t find the relevant part of the loop in my theme file. How do I find the full content with “More…”
  65. posts going to 2 pages/categories only show up in 1
  66. How to repeat a loop after 4 posts [duplicate]
  67. Custom Post Type Single Loop Outputting Wrong Post
  68. Using the loop to set locations for all posts on a single google map
  69. How to separate each individual blog post?
  70. How to get post id of last approved comment?
  71. Defining ‘last’ class on foreach blog posts
  72. How to get the post id (of the parent custom custom type) in a loop inside a widget?
  73. Get current taxonomy and display query accordingly
  74. How to show full post on home page
  75. Error while excluding a post from another loop (using its ID)
  76. Is there a way to define the $post var outside the loop?
  77. ACF flexible content block not showing on live site (works locally)
  78. Only the most recent post is showing on my category page (working on localhost, not live site)
  79. Want to change the post every three days with in specific category
  80. Featured Images most often doesnt appear
  81. Separate top level categories on archive-product.php by meta
  82. While loop in functions.php outputting the_title() of each post on frontpage
  83. Post meta not working
  84. Shortcode for Comments and Comment Boxes in Post Loop
  85. How to bulk Update URLs to new values?
  86. Select another post in a post meta like a parent page is selected while editing a page
  87. SQL DELETE multiple post_meta on single and multi-sites
  88. Permalink Short code showing unnecessary link text inside the loop
  89. Get post slug and match with menu item slug to change css
  90. WordPress Post ids big increment
  91. Reuse old post ID for new post after deleting post
  92. Current post categories and subcatecories outside of the loop
  93. Private post caught in endless redirect loop
  94. How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
  95. Multiple post in One Loop in wordpress
  96. What is proper filter or hook action to add data to the $post object?
  97. Display specific posts based on an ID of another post
  98. Numbered Pagination Showing The Same Posts After Altering WP_Query
  99. “read more” redirects to the wrong page
  100. Diffrent layout for posts [duplicate]
Categories posts Tags id, loop, post-meta, posts
Foreach loop returning more than one item when querying taxonomy
Where can I find linked fonts in my theme?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress