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();