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:
- WP_Query vs get_posts
- What is the most efficient way of querying posts based on visits and date for current day?
- Query WooCommerce orders where meta data does not exist
- When should you use wp_reset_postdata vs wp_reset_query?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Show only oldest post by author
- Order posts by tags count?
- Add and in the header while looping over custom query in page template
- Which custom query am I in and how can I access its properties & methods?
- Dynamically Override Fancy Title – Part II
- How to speed up wp_query, took more 5s to run against 100k posts
- Get the post permalink within the loop but without additional DB query
- List the 5 most recent child pages
- How do you query wordpress posts using a math formula between multiple meta field values?
- Custom Post order for homepage
- Get image of latest post from taxonomies/categories
- Page navigation doesn’t show when query category
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Undefined WP_Query::has_posts()?
- Is it possible to dynamically get queried term AND taxonomy?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pull post meta with post_query?
- Query total number of posts
- How to access a query twice in different template files?
- Creating a custom search for a specific post type
- Minimize database queries to user tables?
- Query all published post AND attachment with specific mime type
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Get all products which have both product category
- unable to retrive parent page information
- How to display user order by role
- How to use the query hook/filter?
- WP Query related posts by tags
- Order by summing multiple values
- Query posts intersecting tags and categories
- Order by empty custom field
- Check if loop has any categories?
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- Query Page Content From Theme Options?
- Query only the posts with a post format of “audio”
- Include current post into loop
- pre_get_posts – Trying to get property of non-object warning
- WordPress query posts with multiple post_meta data
- Yoast primary category query modification
- Update query for wp_posts and wp_postmeta
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Write WP Query that selects posts that are part of the same two categories
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- Include one page/post into query which is already returning posts
- Insert images into wordpress post with a query
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Filter products on category AND tag
- pre_user_query vs pre_get_posts
- Exclude post from wp_query based on custom field boolean
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- How to get meta key list efficiently?
- Order posts by tags count?
- Why pagination is not working with tax_query param?
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- Add to search posts query array with post IDS which will appear first
- Search has query that will return no results
- WP Query – Search in title or author_name
- URL to Post Archive of Custom Query
- Query by meta value (add a dropdown of all values)
- How to show terms from another taxonomy
- My entry results are not consistently alphabetized
- Ignoring ‘a’ when sorting posts
- orderby in WP_QUERY – Use the order from the Dashboard
- Random posts in WP_Query when searching by tag
- Custom query for tag and custom tag from 2 post type
- wpdb get_results() returns only 2 rows
- Query posts in current category but not attachment format
- WP_Query secondary query failing
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- Combine privileged users array with my current query
- add_query_vars does not work
- Pagination not working with WP_Query (creates links but no page)
- Query custom post type by date field only working when two posts match the query
- meta_query dates from an array
- Divide WP_Query posts by date & post type
- Retrieve posts in custom post type and specific taxonomies
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- Get WP_Query query after execution?
- A Depth Like Parameter For “get_posts”
- Search query alteration not working for meta values
- Advanced Search – Is this possible?
- Use value from meta key array for use in WP_Query