Solution for : Get post based on meta field content in WordPress.
The important thing is that we are querying for posts using at least the three criteria of the post type, meta key, and meta value.
For example, let's assume wer custom post type is just called "player" And, each 'player' post has a meta field attached called "player_team"
we could then query for those posts using something like this:
$teamname = ""; // the player's team that we're querying for $myquery = new WP_Query( "post_type=player&meta_key=player_team&meta_value=$teamname&order=ASC" );
No comments:
Post a Comment