$id
isn’t set anywhere in your code snippet. get_the_title( null );
returns an empty string. If you want the title of a post, you’ll need to set $id
to a proper post ID.
(Also, $args
) is unset in the code you’ve posted, and I don’t see anywhere that you use query_contents
either.)
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- Wp get all the sub pages of the parent using wp query
- How to query for most viewed posts and show top 5
- WP_Query vs get_posts
- Query Custom Meta Value with Increment
- Get posts by meta data OR title
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- Show only oldest post by author
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Change query_posts to WP_Query in page but does not work
- Custom Query num_rows returns wrong amount
- Slow page loads due to WordPress Core Query
- Query Page Content From Theme Options?
- How can I override one post and make it display content for another post?
- Include current post into loop
- Filter post query to only show direct children of category
- Should I reset $wp_query?
- Why doesn’t my WP Meta Query return any results?
- Filter products on category AND tag
- pre_user_query vs pre_get_posts
- Get posts that match defined arrays of tags
- I need query_posts() to order results first by a meta value and then by post ID
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- Ordering Posts by parent category, name ascending
- Optimising specific Query with ACF meta objects
- How to organize a WP_Query’s list of posts by category and display category title?
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to query post ids liked by the Author
- WordPress Query showing multiple titles
- Query Posts by date range with fixed beginning and end
- custom query to get posts
- When to use WP_query(), query_posts() and pre_get_posts
- Make a WP Query search match exactly the search term
- Query WooCommerce orders where meta data does not exist
- How to know which one is the main query?
- get query’s query string
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- How to get the posts published in last two days using WP_Query?
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- Can not switch the queried post in pre_get_posts hook
- Get the post permalink within the loop but without additional DB query
- List the 5 most recent child pages
- Query total number of posts
- Creating a custom search for a specific post type
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Custom query for sidebar isn’t returning results
- Query last updated posts (posts updated in the last 24 hours)
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- new WP_Query(), have_posts() return false in user_register hook
- Query posts intersecting tags and categories
- Some doubts about how the main query and the custom query works in this custom theme?
- Different Ways to Query Custom Post Types?
- Query all posts if multiple meta key don’t exist
- Modify Search Query if original Query gave no results
- Query_posts works when appending via AJAX call wp_query doesn’t?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Posts Query | Query to only show sub categories
- How do I add a relation parameter to my filter query?
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Show single posts date, in a page of posts
- specific post is not excluded from the loop
- Unable to paginate a custom page query
- Paginate pages with dynamic query
- Trouble Making WP_Query paged
- Determine if ID is page or post and query the ID
- Query pages created by deleted users
- Exclude post from wp_query based on custom field boolean
- Order posts by tags count?
- trying to change from query_post to WP_Query
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- return child post if available otherwise parent post
- Search has query that will return no results
- WP Query – Search in title or author_name
- URL to Post Archive of Custom Query
- How can I modify standard search query to include also ACF custom fields values?
- Custom WP_query and integrating into theme file
- WP_Query with child element
- How to get query results for the next page
- Loop through multiple custom fields with increasing number
- Need help setting up a search form for wordpress [duplicate]
- query post based on comparison
- Query Posts From Multiple Post Types
- Multiple loop for “featured” items returns wrong posts
- Get WP_Query query after execution?
- Query Posts to fetch Posts with Unique Tag
- query_posts problem – need help
- Search results stuck on page 1
- Use value from meta key array for use in WP_Query