I'm trying to create a custom query in Wordpress. I wish to get it pull-up any posts which are labeled highly relevant to the page that individuals take presctiption. IE - If they're around the Bay 198 Skatepark page, additionally they see a listing of Bay 198 Skatepark posts.
I have become the custom query to operate, however i need this to become dynamic to ensure that if you're around the Bay 198 page, the thing is individuals posts, but when you are well on the truth Skateboards page, the thing is individuals specific posts.
The simplest way I possibly could think to do this was to produce a custom area on each page that might be just like the tag which way I'd just complete the tag for every page like a custom area also it would return the posts.
The problem is the fact that I can not learn how to implement the custom key call in to the custom query. Here's my code to date, that one being the one which works:
<?php $second_query = new WP_Query(' tag=bay-198&posts_per_page=500 '); while( $second_query->have_posts() ) : $second_query->the_post(); ?>
I simply need to learn how to replace that "tag=bay-198" and also have it dynamically pull within the tag in line with the page.
Hopefully which makes sense, I appreciate any help.
Use a variable that containts the need for your custom area. Adding that variable in to the query like so:
<?php $mykey_values = get_post_custom_values('my_key'); $tag = $mykey_values['your-custom-field']; $second_query = new WP_Query(' tag=' . $tag . '&posts_per_page=500 '); while( $second_query->have_posts() ) : $second_query->the_post(); ?>