Hello
Thanks for this theme – it’s excellent and the best I’ve tried yet!
I would like to overlay the category name as a link on an image in the post loop. I did some tweaking to loop-grid.php and managed to get the category name to display above the image as plain text. However, I’d like to overlay it on the image with an opaque background. The Smart-Mag theme does this:
http://themeforest.net/item/smartmag-responsive-retina-wordpress-magazine/full_screen_preview/6652608
Here’s the code I tweaked for loop-grid.php
<?php /** * Loop Name: Grid */ ?> <?php if( have_posts() ) : $i = 0; ?> <div class="vantage-grid-loop"> <?php while( have_posts() ): the_post(); $i++ ?> <article <?php post_class(array('grid-post')) ?>> <?php $category = get_the_category(); if($category[0]){ echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>'; } ?> <?php if( has_post_thumbnail() ) : ?> <a class="grid-thumbnail" href="<?php the_permalink() ?>"> <?php the_post_thumbnail('vantage-grid-loop') ?> </a> <?php endif; ?> <h3><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3> <div class="excerpt"><?php the_excerpt() ?></div> </article> <?php if($i % 2 == 0) : ?><div class="clear"></div><?php endif; ?> <?php endwhile; ?> </div> <?php vantage_content_nav( 'nav-below' ); ?> <?php endif; ?>
Hi
Thanks for your positive feedback, glad you’re enjoying the theme.
Please be sure to keep any edited files in a child theme. Changes within the Vantage folder will be lost during theme updates.
How’s your CSS? Here is an example CSS section from another theme, the most important property is opacity:
So in summary what’s happening there is the container that the title is in is being absolute positioned and then given opacity: 0; On hover the opacity is being changed to 1.
Hope that helps steer you in the right direction.
Thanks for getting back to me. I’ve got it looking how I want with the following PHP & CSS changes:
That’s looking great. Nice improvement for sure. Sorry, I thought you wanted a title to appear only on hover. For anyone else reading, that wasn’t required, so the opacity setting isn’t needed.
Thanks for sharing. Glad you were able to take my example and make it happen.