How to set a custom field value as php variable controling a wp_query?
-
Hello there,
I have the following problem. I’m programming the page for a small publisher. They have a lot of artists under contract, each with different items. I want to display the items beneath the artists posts.
I thought I give each artist item the same tag, for example “artistone”. And then create a custom field – called “ItemTag” with the value “artistone” – in the artists post. then I want to use this value as the value tag via wp_query to call for the posts with these tags.
It has to be as simple as possible, because the client is unable to do any coding … So the client only has to set up the custom field and put in the name of the artists items tag to show his/her items at the bottom of the post.
But I can’t get the value of any custom field set as tag value. This is what I have so far:
<?php $variable = get_post_meta($post->ID, 'ItemTag', true); //The Query query_posts( 'tag=$variable' ); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php include(TEMPLATEPATH . '/custom-mini-product.php'); ?> <?php endwhile; else: endif; //Reset Query wp_reset_query(); ?>
The “custom-mini-product.php” is just the post info in a separate file – because I need to use these multiple times …
Thanks for any help ??
- The topic ‘How to set a custom field value as php variable controling a wp_query?’ is closed to new replies.