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
- WooCommerce: List All Categories
- How can I hide a category from Contributors in the edit/add new post screen?
- Multiple post categories – single permalink
- Wrap Post count in a span
- Display all posts with same title
- Show children of top level category only
- hide specific categories from showing
- Category Search functionality on category metabox (wordpress admin)
- how do I filter single_cat_title to remove all instances of a particlular word
- Category page shows Oops! That page can’t be found
- How can I enable a TINYMCE rich text editor in the admin interface?
- query order by category
- Shortcodes not working in category or tag description
- Best way of getting WooCommerce category path
- Order categories by name or view count
- Give a page priority over a category that has the same name?
- How to rewrite the post URL according to the category?
- ajax for filtering posts by category in wordpress loops
- Create category post shortcode
- Question on using custom structures for categories
- Tags Instead of Category
- Generating a feed of all but one category of posts
- How to add categories using mysql
- Display all categories but only if they have posts in them that have a specific tag assigned
- How to fix select filter on category
- Show audio player only in specific post type category
- Check with Jquery if second level checkbox from categories are checked
- Regarding Tags And Categories
- How to show entries related to main category
- selecting categories that have products with tag/category
- How to get WooCommerce Product Categories and its children’s children?
- Media Library Category Exclude Tree
- When category name and title are the same … WP will select archive.php instead of single.php
- How to display child-category PAGES on a category page
- How get all media from a posts category by db?
- Cant get unique_array() work on get_the_category() foreach loop
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- how to Specifies an author / editor to edit one category only?
- Formating content in category.php
- Display post content from category name using ajax
- How to display the category featured images [closed]
- Echo Category In Loop
- hide_empty property not working when using get_terms
- Hierarchical outline of posts
- Advanced Search – Is this possible?