It sounds like you’re just looking for get_post_meta()
. Using your custom field of issue_number
, you’ll do something like this (untested):
$issue_number = get_post_meta( get_the_ID(), 'issue_number', true );
$my_issue_query = new WP_Query( array(
'post_type' => 'issue',
'tag' => 'issue-' . $issue_number,
'posts_per_page' => 50
));
Note: While the code you pasted may work, you don’t want to override the $wp_query
global with a new WP_Query
instance. Rather, use a new prefixed query-specific variable to hold the query instead and then call it like $my_issue_query->the_post();
Related Posts:
- How do I query for posts by partial meta key?
- Display products from specific category in shop page
- How to uniquely identify queries?
- meta_query where value is equal to given value
- Query by meta_key and order by meta_value_num return orderby date
- How to display most recent posts that haven’t already been displayed with WP_Query?
- What is the difference between these two custom queries?
- WP Query post meta value
- Display featured products through custom loop in WooCommerce 3 [closed]
- Query wp_usermeta alongside wp_users
- Understanding the use of wp_reset_query();
- How to exclude products by tag from woocommerce shop page?
- Multiple WP_Query loops with Pagination Not Working
- WordPress posts per page WP_Query
- WordPress WP_Query orderby being overwritten
- Multiple meta queries but arrange by specific meta value order
- WooCommerce Only OnSale Products Loop Snippet [closed]
- Query post with meta_query where date is not in future
- What format does the meta_query TIME type require?
- WP_Query date_query – Use unix timestamp?
- pre_get_posts order by not working
- WP_Query last five posts, simply ordered by meta_value
- How to display specific posts with WP_Query?
- WP_Query “OR”: Find posts by ID, Name or Post Title?
- What is the random string I am seeing when I use get_query_var?
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- How to get all child pages in their parent page?
- WP_Query order result by date AND meta_value
- How to display summary content from a Page (Not a Post) on another page
- Custom Search Not Consistent with Results
- how do we display all posts from a particular category in homepage?
- Display both standard posts in a specific category along with a custom post type in a single loop?
- Orderby is working with one query but not with other
- meta_query in WP_Query value is not accepting array
- Is there a way to work with a specific the_field from an already queried post? [closed]
- Add capabilities via plugin for another plugin
- Two loops on archive page
- How to order posts by title after they have already been sorted by category
- Filter and Order by Multiple Custom Meta Values
- Meta Query relation “AND” then set array accordingly
- How to query custom post types with mixed AND & OR statements for custom fields
- Query with meta_query and tax_query together not working properly
- Adding a tax_query to a WP_Query Object
- wp_query search not taking keywords with together for multiple words
- Adding a html class based on post count
- meta_query fails to compare on values containing apostrophes
- Combine 2 arrays in a query parameter
- Add ACF field in a query
- Set front_page programatically after user login via query, while leaving site option alone
- How to Display Shortcode in the correct location, currently displaying before content after Page Title?
- Filtering posts by archive showing all years
- Find all product ID from array of customfield
- WP_Query posts_per_page strange caching
- wp_query show all values
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- Hiding carousel indicators if there’s only one post
- add_query_arg to compare and display events from a certain date
- WordPress dynamic AJAX query
- Custom Taxonomy Breaks Pages
- Using rewind_posts for displaying multiple categories
- WP_Query and pagination AGAIN?
- Page template doesn’t display simple HTML if inserted into other page?
- Query multiple post types, but different order for each
- How to add date_query to meta_query array
- Order by the first array within a meta_query
- Nearby locations using Advanced custom fields, maps?
- View list of custom posts within a date range relative to today’s date, based on a custom date field
- Multiple nested meta queries
- How to display the category dropdown auto search list when key press?
- order by post date and modified date posts both in wpquery
- Comparing Meta Field date in WPQuery using Meta_Query?
- Fix wp_term_relationships slow query in get_posts
- Custom query for custom post type not getting correct post ID
- How to merge these two post queries?
- How to search posts by title with special characters in WP_Query?
- Query postmeta based on meta_value, return array of post_id
- WP_Query: Query posts only if their access is restricted to logged user’s role
- datetime picker, timestamps and meta queries
- Get specific value from variable to use in query
- WP_Query with meta_query won’t orderby
- Adding Category in WP_Query Not Working
- Meta key in wp_query bug?
- display all posts from category with and without terms in chronological order
- How can I create another instance of my custom shortcode
- How To Call WP_Query From A Subdomain?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- WordPress: Cron locking and Queue
- Correct Way To Run Multiple Queries Sharing Some Base Data
- how to query for meta_value have array
- How to make the default WordPress search return borader results
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- Show sticky post before other WP_Query
- List ALL posts within last week from current category on category page
- WP_Query on “property” in the options table
- Post OrderBy slow performance
- Showing posts from 4 categories along with all latest posts
- Searching in specific custom post type
- WordPress pagination returns the same posts
- Hook to get the query result after listing posts
- Display post format post in the sidebar