• is there anyway to put a variable into the wp_query()?

    for example, I’m trying to assign a custom value to a variable, and then use that variable to draw only a certain tag

    <?php $tagvalue = get_post_custom_values("flipbook"); ?>
    <?php $flip = new WP_Query('post_type=post&tag=$tagvalue[0]'); ?>

    this is what I have so far.

    I basically just want whatever value I attribute to “flipbook” in the custom values to become the tag in the query.

    Hope this made sense.

    Any help would be much appreciated.

Viewing 1 replies (of 1 total)
  • I think you just need to append the tagvalue to the WP_Query argument string, like this:

    <?php $flip = new WP_Query('post_type=post&tag=' . $tagvalue[0]); ?>

    You probably also need to handle the case where no tagvalue is found.

Viewing 1 replies (of 1 total)
  • The topic ‘putting a variable in WP_query’ is closed to new replies.