How can Get the Category ID??
-
Hello all.
I need help in something.
I have set up the “The Attachment Image” Plugin which is working good.
What this plugin does is to display the first image of your post in a thumbnail. This is working good in the home page (I show off some products with no excertp, just the image linked to the post). To display this i have to put in the loop this code:<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <strong><?php the_attached_image(); ?></strong> <?php endwhile; ?> <?php endif; ?>
What i need to do is to display thi first images of a certain category, which i can comply by writting this in the loop:
$my_query = new WP_Query(‘showposts=2&cat=3’);
while($my_query->have_posts()) : $my_query->the_post();
the_attached_image(‘img_size=thumb&css_class=image’, $my_query);
endwhile;What I want to do is to print the category ID of the category link I cliked, I don’t know if i’m making myself clear, english is not my native language.
I need something like:
$my_query = new WP_Query('showposts=2&cat=<strong><?php SHOW CATEGORY ID?></strong>'); while($my_query->have_posts()) : $my_query->the_post(); the_attached_image('img_size=thumb&css_class=image', $my_query); endwhile;
I hope someone understand what i just wrote. Thanks in advance.
- The topic ‘How can Get the Category ID??’ is closed to new replies.