putting a variable in WP_query (2 posts)

  1. screenwords15
    Posted 5 years ago #

    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.

  2. vtxyzzy
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic