Customising post on home page depending on category
-
Hi friends. I am hoping a guru can help me, as I am way out of my depth.
Currently my index page pulls in one thumbnail image from my posts and displays them in a grid. When you rollover the thumbnail, the title and excerpt of the post hovers over it. I want to be able to customise this so that it only shows the title and excerpt of the post if it is from my category called ‘Projects’. If it’s from another category (ie ‘News’) I don’t want the title and description to appear, My current code is below and the three categories (Home, Projects, News) are already setup in the system.
Does anyone know how I can edit this code below to achieve the result I need? Basically it needs to work in the following logic “if a post is flagged with the ‘Home’ category, then show it’s thumbnail on the home page and display it’s title/excerpt hover when it’s rolled over, however if the post is also flagged under the ‘News’ category, then show the thumbnail, but don’t show the text/excerpt hover for it.”
<?php query_posts('cat='.get_cat_ID('Home')); if (have_posts()) { while (have_posts()) { the_post(); ?> <div class="project-image"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> </a> <div class="hover"> <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1> <?php the_excerpt(); ?> </div> </div> <?php } } wp_reset_query(); ?>
- The topic ‘Customising post on home page depending on category’ is closed to new replies.