Couple of issues here
-
IIRC,
excludeshould be an array of ID’s asexcludeget passed toWP_Queryaspost_not_in -
You are defining arguments which you don’t use. You could have simply passed that to
get_posts. Rememeber, all parameters inWP_Queryis available as is toget_postsasget_postsusesWP_Query -
You can simply use
'offset' => 1,to skip the most recent post. You are running total unnecesarry queries here which slows your page down
You can try the following
$args = [
'posts_per_page' => 5,
'offset' => 1
];
$recent_posts = get_posts( $args );
Related Posts:
- Keep featured content post in homepage with original order
- How to show related posts by category
- the_author() returns empty string
- Display all posts from specific categories on a page
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- How to display posts by current user/author in a custom page template?
- post_name empty after wp_insert_post
- WordPress Posts Out Of Order after 3.1 Update
- Query only Posts from Both of Two Category?
- Insert custom div between posts
- Order post by year DESC and month ASC
- WordPress get posts by date without query_posts
- How to Display Post View Count
- Different amount of posts on homepage than paged pages
- Featured Posts for Category Pages
- Cannot Update A Post, 404 Error
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- How would I get 1 latest post from a query for 5 posts?
- Exclude posts with empty post_content in wp_query
- Create dropdown list post
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- previewing my posts on static page?
- Inserting custom data to the_post() during loop
- is there a way to show the the post title after the image?
- Display all posts that were published before full post on single.php
- Category Foreach keeps looping?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Random ajax load only works with posts_per_page set to -1
- Display an author’s posts on his own author page
- How to make multiple sections in home pulling posts category wise?
- Order posts alphabetically: how to set order=asc in mysql query?
- How to order posts in an arbitrary order?
- How to get posts from a current post’s month?
- Wrong post title displayed from loop
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- While loop articles – if statement order
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Conditionals if tags exist?
- WordPress website loads more posts than expected
- Get the amount of posts on a current page
- query post limits
- why the same code got different results when using query_posts in functions.php and index.php
- Display Posts with template on a Page
- Archive template combined with post slider and regular posts
- How to get posts published on the latest date?
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- Post Filtering by GET URL parameters
- On what hook can I get the queried object’s final state?
- Get the most recently modified post date of most recently modified post
- WP_Query: Show 10 posts in date order, first three random
- Get post by tag
- Random posts that always include a particular post?
- Bootsrap carousel for post
- All categories displays the same posts
- Query function not executed between element [closed]
- Echo the number of posts being displayed
- Exclude a category of posts in author template
- Display specific posts on home page
- WP_Query articles order by offset in collumns
- Trying to query all posts in category 4
- Getting posts from some categories plus some individual posts
- Get posts from current category?
- Change content off every sixth element
- Move position in post list for a custom checkbox column
- How to merge the content of posts that have the same title?
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- Displaying all posts from other sites on the network on one site
- How to display particular categorie’s post which associated to specific user?
- wp_query args with relation
- Querying posts from current category, using a variable as array argument
- How to correctly escape data
- Use special template for the first post in the loop
- Repeating post how to solve this
- Sort Events by Venue Title – Sort Post set by related post ids
- Need help writing loop to display posts by categories in separate divs
- Get posts by category or author
- Query post category & remove any post id
- show latest authors blog post
- How to get only current images of a post
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- How to pass multiple checkbox values to wordpress query?
- How to limit the number of results for all query_posts on mysite
- How to get all post titles starting with numbers and symbols?
- How to inject a post within a loop
- wp_query select if have comments
- Creating pages and getting their values from the database table
- How to limit post query to only return a total count of items with certain post statuses?
- Not displaying any articles on a custom made file
- query_posts different amount of posts per page [duplicate]
- Dynamic archive of posts by date
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Why does ‘get_the_ID’ work outside of the loop?