[resolved] Pulling post based on more then one parameter (3 posts)

  1. GabyVazquez
    Posted 6 years ago #

    Earlier I had found a solution, but realized that it was not working as intended. So my original post it had been suggested to run a Query for a specific category then run the script below. Unfotunatly it also stopped my other posts from displaying.

    So again, the code below is looking for specific posts which have the custom field thumb. I'd like to have the code still pull all the posts with custom field thumb, but would ALSO like it to pick out only ones based on a specific category

    if ( get_post_meta($post->ID, 'thumb', true)) {?>

    is there a way to have it filter the posts during this part of the code to pull specific categories. for example

    if ( get_post_meta($post->ID, 'thumb', true))AND from Catagory id 1 or Category name {?>

    Any ideas?

  2. MichaelH
    Posted 6 years ago #

    So assuming you don't want to use any of the various arguments available as described in the query_posts article. For example:

    query_posts($query_string. '&meta_key=thumb&cat=1');

    then, you will want to use the in_category() conditional tag in your loop.

  3. GabyVazquez
    Posted 6 years ago #


    <?php if ( get_post_meta($post->ID, 'thumb', true) && in_category('5') ) { ?>

    worked perfectly...thanks again for all the help!

Topic Closed

This topic has been closed to new replies.

About this Topic