That’s a really inefficient way to do it.
Just use the $count variable you declared at the top, without any query_posts():
$count = 0;
while ( have_posts() ) : the_post();
if ( $count < 1 ) {
// first post
} elseif ( $count <= 4 ) {
// next 4 posts
} else {
// rest of the posts
}
$count++;
endwhile;
Also, it’s ‘showposts’ not ‘showpost’. Or use the newer ‘posts_per_page’.
Related Posts:
- is_category() in pre_get_posts strange error
- Rearranging posts based on categories
- Custom Query to search through categories
- How to query all posts of a specific category, and any other category combination
- is_category in pre_get_posts results in php notices
- How to Check if a Child Category is Being Queried
- How Do I Merge Categories With phpMyAdmin
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- If newest post of category is newest post in general, skip first post of category
- Disallow categories from this MySQL query
- Include posts from feature category in pre_get_posts
- How to display posts under a specific subcategory of a given category
- get_the_category and echo out link to child-most/deepest category
- query in category.php repeats itself
- Display posts separated by Category in Author’s page
- Category param redirect to post type archive
- How to get related tags based on a category?
- Show popular post by category code
- How to get latest posts from each category in regular order
- category pagination got broken suddenly
- How to query categories with Advanced Custom Fields?
- Where and when does WordPress invoke routes
- And/Or Category Query
- Exclude category from query
- Overriding default calendar to show posts from a category
- function query_posts disabling current_page_menu class
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Using in ‘category_name’ in ‘$query->set();’?
- custom query for both category and pages using global $wpdb;
- Get categories of queried posts
- Query from multiple category (and)
- How to display posts from specific category using get_option function?
- SQL query to get posts from multiple categories but not in a category
- Conditional category query breaking?
- How to filter post from categories only if the posts appears in one of them, not the other?
- Category name for all posts getting assigned to a single random post
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- List of post categories only associated to another custom taxonomy
- how tho change number of posts in loop from specific categories
- Get category from slug list
- Issue with WordPress category search
- Querying posts from two different categories while looping inside another loop
- how to get postmeta info based on multiple categories?
- Too many categories drastically slow down my website
- How to get posts from many categories using WP_Query
- Is it possible to query the result of a query?
- show posts found in multiple categories via category_name query string?
- Match two taxonomies to display a specific content
- Category slug in in loop always the same?
- display certain category on custom template page
- Detecting top parent category fails on home page
- How to use Greek characters/letters in a query?
- Displaying posts by year
- wordpress category.php query for featured news item, broken pagination and repeating posts
- How to show posts of a specific category
- How to get parent and child sub category (Taxonomy) order to display
- Categories in admin interface: can they be collapsible?
- How to append category name to category ID in a form field
- Equivalent to in_category() for subcategories
- query_post order desc
- Limit number of posts on a custom category template – breaking pagination
- list categories based on updated posts [closed]
- How to create a subcategory to a PAGE on WP?
- How can I only display one link rather than many?
- Hierarchical permalink structure for posts showing categories and sub-categories
- how i can hide some category from author admin panel?
- Display posts from a category
- Finding the category id’s on category intersection pages
- Display sibling categories on category page
- Getting the category title / description returns first matching post?
- I want to know how to output child categories related to parent categories
- Allow user to select categories that will display in post loop
- Echo show_count of categories separately without using wp_list_categories
- Two Sections on Woocommerce Catergory Page [closed]
- How to fetch the highest category in the hierachry for a specific post?
- Woocommerce search form with category select
- Display category title and three latest post inside the category
- Let user select their own category
- Pagination breaks on child-categories, works fine on parent-category
- Is the part “category” fixed to an URL to an archive or post?
- How can I use AJAX with check-box categories?
- List Categories By Specified First Character
- the category city made as a subdomain
- Displaying Single Product Page Parent and Child Category
- How to add the .html extension to the category?
- How to create category filter on a blog like on the site below?
- Get category base permalink
- Wrong category in URLs accepted like the correct one
- Style a category page the same way as the homepage?
- How to Manage and link certain custom taxonomy?
- Store All Post Categories In Array
- How to add an “All” category to the tag cloud?
- Display Taxonomies in loop with template args
- Categories Going to different Blog Pages?
- Display only the latest post
- Change next_post and previous_link to navigate throught parent categories only
- Multiple Parent Category URLs
- What defines a post as portfolio page content?
- How to add location as category?
- Taxonomy term RestApi data 10 rows limitions