Want built in theme gallery to show selected category

I have a theme with a built in gallery but I want the gallery to show only the “featured” category. Here’s the code:

<div id=”myGallery”>

<?php

$my_query = new WP_Query(‘showposts=8&offset=0’:wink:;

while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;

?>

When I try this, it works somewhat but the pictures stop showing up.

<?php

$slidecat = get_option(‘featured’:wink:;

$my_query = new WP_Query(‘category_name= featured ‘. $slidecat .’&showposts=8&offset=0’:wink:;

Any suggestions or links to some similar php to replace in the theme?

  • Kimberly
    • Champion of Loops

    Hi!

    Just checking in :slight_smile:

    I’m guessing that because we haven’t heard back from you that you’ve got your issue worked out! If you are still having problems or need any other answers on this particular topic please feel free to come back to this thread at anytime. Just be sure to mark it Not Resolved so we don’t miss it!

    This ticket is only being Resolved due to lack of activity. It is by no means an action to avoid, brush off or minimize your issue. We are ready and here if you want to re-open at any time and I apologize in advance for any lack of communication if this ticket is being closed in error.

    Thanks for using the WPMU Community!

    Best,

    Kimberly

  • Kimberly
    • Champion of Loops

    Annabelle,

    My coding skills are very weak. However, I would imagine that the $slidecat would need to be included somewhere. My suggestion was a generic combination of the code :slight_smile:

    I’m looking at the page for wp=query in the codex: http://codex.wordpress.org/Class_Reference/WP_Query

    and I see that you can use

    get( $query_var )

    Get a named query variable.

    in a query so maybe adding to the original code instead of replacing it…

    i.e.

    $my_query = new WP_Query('showposts=8&offset=0');
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;

    can be

    $my_query = new WP_Query('cat=4&showposts=8&offset=0');
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;

    I’m not 100% sure about how to add the cat argument to the Query function, but hopefully you see what I’m doing there :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.