We're merging with GenerateBlocks! Learn more here.

Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show categories inside featured images Reply To: Show categories inside featured images

#19597
elvin
Moderator

Hi Liran,

I’ve rewritten the code to work for WPSP. You can try this PHP code out.

add_action( 'wpsp_inside_image_container', function( $settings ) {
    if ( 77 === $settings['list_id'] ) {
        $wpsp_cat_list = get_the_category_list(); 
		$wpsp_category = get_the_category();
		if ($wpsp_category) {
			foreach($wpsp_category as $wpsp_cat) {
			$wpsp_cat_slug = $wpsp_cat->slug; 
			}		
		}
		if($wpsp_cat_list){echo '<span class="cat_links"><span class="'.$wpsp_cat_slug.'">'.$wpsp_cat_list.'</span></span>';} 
	}
});

And style it with this CSS code.

.wp-show-posts-image{
   position: relative;
}
.wp-show-posts-image > a > img.wp-post-image {
   width: 100%;
}
.wp-show-posts-image > span.cat_links { 
   position: absolute; 
   margin:0; 
   top:auto; 
   bottom: 7.5%; 
   left: 5%;
}
.wp-show-posts-image > span.cat_links > span > ul{
   list-style:none;
   margin:0;
   padding:5px;
}

We basically just replaced the generate_inside_featured_image_output hook from GP default with wpsp_inside_image_container for WPSP.

And since WPSP has a slightly different CSS selector, we simply adjust the CSS selectors. We just changed .post-image(GP) to .wp-show-posts-image(WPSP).

Everything else is pretty much the same.