There are some errors in your code, you have to change:
$the_query -> have_posts()to$the_query->have_posts()$the_query -> the_post()to$the_query->the_post()WP_Query array(...)toWP_Query(array(...))'showposts=6'to'posts_per_page' => 6
Try this instead
$the_query = new WP_Query( array( 'category_name' => 'portfolio', 'posts_per_page' => 6 ) );
while ($the_query->have_posts()) : $the_query->the_post();
the_post_thumbnail();
endwhile;
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- WP_Comment_Query pagination, delving into the unknown
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Sort posts by category name and title
- Custom WP_Query order by post_meta and (author) user_meta
- WP_Query for WooCommerce Products
- Get posts by meta data OR title
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- Duplicate Queries
- Highlighting Sub topic in a post?
- How to count post type that has a particular term?
- how to retrieve specific product attribute value in an sql query?
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- WP_Query Performance Issues with meta_query
- WordPress custom archive page
- Query Set Order By Author
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Retrieve or Query Pages by ID
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- How to do a query on custom taxonomies that is uncategorised?
- Empty tax_query array returns an empty array
- Meta Query for specific months
- How do I search inside specific taxonomies in WordPress
- How to orderby meta_value_num with dollar ($) sign
- if/else on custom query gives 200 OK when condition not met?
- How to correctly pass values to wpdb->prepare()?
- Query: offset post list, unless it’s a specific category
- Setting get_queried_object
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- only delete post within query / for each statement (front end)
- Sort query by author: 1 author, then others
- Custom Query num_rows returns wrong amount
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- How to duplicate 5 posts out of WP_Query results?
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Slow queries on a huge database
- WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- How to get list of posts from permalinks?
- Sort WordPress Posts Meta value by Week not Day
- Is_single() conditional tag returns null in query
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- Query posts that contain video?
- Show a 404 error page if Public query variable’s value doesn’t exist?
- Set front_page programatically after user login via query, while leaving site option alone
- Query where ANDing slug values not working
- How to filter query loop block with a search string from the query parameters
- mysql query order by
- Notice thrown when creating numeric pagination on custom query
- How to SQL query posts IDs by categories AND authors?
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- setting offset to category number in archive page
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Query against multiple locations within single custom post type post
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- How to get_comments() ordered by date and parent?
- How to query 5 users in random who have published more than 10 posts
- WP Query. Ordering posts by another post types meta
- How to make a search query if not found in post table then search in postmeta table?
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- How to show post title in content editor in backend?
- Adding Category in WP_Query Not Working
- Merge two queries and remove duplicate
- What is the best way to reset a search on a meta_key / meta_value?
- Fetch only categorized posts
- Bring a post to the top of the query if it’s in a certain category?
- WP_Query with child element
- Custom pagination (Title, date and teaser)
- Using URL variables on a custom WP_Query
- Using WP_Query to re-query and sort results using a date?
- Pagination is not working on custom query inside a custom home page template
- Pagination in custom query in a category page
- Get a list of the last posts grouped by author and filtered by category
- How to query post ids liked by the Author
- WordPress Query showing multiple titles
- custom query to get posts
- confirm my booking with phone number
- Modify query after meta value
- Custom post types loop on a page template
- Showing posts from 4 categories along with all latest posts
- Pagination in WP query with transient API
- Parsing External Table Arguments
- difference between methods of query
- Query posts by meta value and sort by another meta key
- how to use transient method?
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Use meta query only 3 or more results?
- Search results stuck on page 1
- Use value from meta key array for use in WP_Query
- Rewrite URL custom search query
- posts_per_page showing 16 elements instead of 3