Template tags are not methods of WP_Query
object. They are functions.
On the other hand have_posts
and the_post
are methods of WP_Query
.
So in your code you should use:
while ($test->have_posts()) : $test->the_post();
as you do, but then:
echo get_the_title();
echo get_the_content();
Also… if you want to echo these values, it would be much better to use the_title
and the_content
instead – there are some additional filters and actions fired up.
Related Posts:
- Can wp_query return posts meta in a single request?
- Broken? WP_Query and “attachment” as a post type
- How to use the_posts_navigation for wp_query and get_posts?
- Secondary Sort (fallback) for WP_Query
- How to paginate attachments in a secondary query as gallery?
- How to stop wordpress to make the default query?
- How to make an activities stream mixing posts and comments?
- Single page theme that uses pages for the content
- Order posts ascending with number in title
- using wp_query to return posts w/ comment count > 0
- Order by meta_key in custom post type doesn’t affect the query
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- wp_transients | wp_object_cache VS SESSIONS & Cookies?
- How to hide post content/meta from everyone except the post author and admin
- Add a default meta_value to new posts
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Too many posts cause slow load when paginating
- When querying a combination of posts and other meta fields, is there a better solution than directly modifying the WHERE value?
- Order Posts by meta value AND published date
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- Multiple taxonomy And acf filter group by
- Get number of authors
- How to display upcoming events by dat with Modern Events Calendar Lite
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Wp_query Add specific pending posts
- How to Filter Posts by Custom Fields?
- WP_Query orderby author__in
- Take all produts by category
- How can I display a custom field from all posts and order them individually from their parent post
- pagination with ‘no_found_rows’ => true,
- Query posts from category A, and from either category B or C
- meta_query not working as expected
- How to retrieve the date on which a post was moved to trash?
- wp_query with parameters
- Query posts with “non set” meta value
- Add filter post_where and passing post_type argument
- WP_Query infinite Loop
- Ordering a mysql style datetime stamp with meta_query
- Advanced WP Query and/or
- 2 wordpress loops showing 1 post from same post type – how to avoid showing the same post?
- wp_query get data from advanced custom field in wordpress
- WP Query – order posts by meta field first and then order the rest
- Reusing content from front page on sub page
- Get Child Page IDs by Parent ID
- Wildcard search in WP Query
- Especific order by Custom Field Values in WP_Query
- Create a notification for post field
- Querying a large number of posts including their custom fields data
- Group posts by attachment meta key
- date_query is showing duplicate results
- How to query posts for custom post type with featured image for first 2 post?
- Why is get_the_excerpt returning full content
- Randomly pick one testimonial post
- WP_Query with 2 genres
- Display posts from an array of ID’s
- Date not appearing in custom query
- Custom post type – filter content by custom meta box content
- Trying to output content from page, works locally but not online
- How can I modify the query by adding to the existing query?
- WP_Query Regexp whitespace and end of string
- Custom order of posts in wp_query and different taxonomies
- Update wp_query every week
- Count post meta entries
- use mysql variable in a $wpdb->query to reindex a column?
- wp_insert_post with ACF Fields and WP Meta Query returns no rows until update
- Query WP Posts, then list the taxonomies from those posts
- Search with WP_Query, but ignore href URLs in anchor tags?
- Displaying Pages in Nav Sub-Menu with Specific Taxonomy Terms?
- Multiple meta_query not working
- Is meta_key used for ordering, filtering, or both?
- compare for multiple meta values for same key in wp_query
- Save query in function for custom gallery
- Merge two queries and remove duplicate
- Convert SQL Query to WP_Query
- Taxonomy Terms That Don’t Exist Display Results
- Why is my query not giving results?
- Get a page ancestor from a most viewed list
- What argument does my function need to echo get_results() query results
- Custom pagination (Title, date and teaser)
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Sorting Posts with meta value not working
- Display posts from catagories
- Add pagination to table generated by wp_query
- Adding a Theme Customizer Control for Posts_Per_Page
- Fire query on ajax post url page
- using next-page and previous page inside a wp_query
- Custom query from all posts & all child page from one parent page?
- What is wrong with this pagination code?
- wp_query conditionally get posts
- how to add limit records in wordpress query
- query only direct child and sub-terms of a current term archive
- restrict posts per page
- the_excerpt() not working in custom archive
- WP_Query by meta key not returning any posts
- How do I subquery with custom meta fields?
- Show number of posts AND number on current page (cannot make it work)
- Advanced Search – Is this possible?
- How to include custom fields in wordpress search