Support » Fixing WordPress » Hiding post title in a specific category

  • Hey guys.

    I’m using a theme called Resi, a very good use for a photo-blog, highly recommend it. I’m trying to hide a post title that is being displayed when hovering over images, but only on certain categories. My “client” wants hovering post titles to show up only on posts that is in a category called “commercial”. The solution I have so far is to not give posts any titles except for the ones in “commercial”, but I don’t like to not being able to see the post titles in the editor. So, I found this thread since 4 years back, https://wordpress.org/support/topic/hiding-post-titles-in-a-specific-category, and it seems to work for her, however, I don’t know much PHP unfortunately and I have tried various ways to get it to work, so I was wondering if anyone knows how to do this correctly, any help would be very appreciated.

    So, here’s the arhive.php from the theme, I think this is where I should make the changes, let me know if this is NOT the place to look for:

    <?php
    /**
     * The template for displaying archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package resi
     */
    
    get_header(); ?>
    
    	<?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_category_layout', 'option1' ) ) ) : ?>
    
        <?php else : ?>
    
        <div class="grid grid-pad">
    
            <div class="col-9-12">
    
        <?php endif; ?>
    
    	<div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
    
            <?php
    		// Check if there are any posts to display
            if ( have_posts() ) : ?>
    
        	<?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_category_title' ) ) ) : ?> 
    
        		<header class="archive-header"> 
    
    				<h1 class="cat-gallery-title">
    					<?php printf( __( '%s', 'resi' ), single_cat_title( '', false ) ); ?>
                    </h1>
    
    				<?php
    				// Display optional category description
     				if ( category_description() ) : ?>
    
                	<div class="archive-meta">
    					<?php echo category_description(); ?>
                    </div>
    
    				<?php endif; ?>
    
    			</header>
    
        	<?php endif; ?>
    
    			<section id="gallery-container" class="default-gallery">
                	<div class="grid-wrap">
    
    				<?php while ( have_posts() ) : the_post();  ?>
    
            				<?php if ( has_post_format( 'image' )) { ?> 
    
                                	<?php $resi_filter_effect = get_post_meta( $post->ID, '_resi_filter_effect', true ); ?> 
    
                                	<?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_image_link', 'option1' ) ) ) : ?> 
    
    									<a
                                        	href="<?php echo wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ) ?>"
                                            class="gallery-link"
    										<?php if ( get_theme_mod( 'active_lb_content' ) == '' ) : ?>
                                            	title="<?php the_title( '<h3>', '</h3>' ); ?>"
                                                data-description="<?php echo the_content( '<p>', '</p>' ); ?>"
                                            <?php endif; ?>
                                        > 
    
                                    <?php else : ?>
    
                                    	<a href="<?php the_permalink(); ?>"> 
    
                                    <?php endif; ?> 
    
                                    		<figure class="gallery-image">
    
                                            	<?php if ( get_theme_mod('active_hover_effect') == '' ) :
    
    												$resi_hover_content = get_theme_mod( 'resi_hover_content', 'option1' );
    
            										switch ( $resi_hover_content ) {
    
                									case 'option1': 
    
                                                		the_title( '<div class="image-title"><div><span>', '</span></div></div>' );
    
    												break;
    
                									case 'option2': ?>
    
                                                		<div class="image-title"><div><span><?php the_excerpt(); ?></span></div></div>
    
                    								<?php break; 
    
                									case 'option3': ?>
    
    													<div class="image-title"><div><span></span></div></div>
    
    												<?php }
    
    											endif; ?>
    
                								<?php the_post_thumbnail( 'full', array( 'class' => $resi_filter_effect )); ?> 
    
                                            </figure>
    
                                    <?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_image_link', 'option1' ) ) ) : ?>
    
    									</a>
    
                                    <?php else : ?>
    
                                    	</a> 
    
                                    <?php endif; ?>
    
                            <?php } ?> 
    
    				<?php endwhile; ?>
    
            		</div>
    			</section> 
    
    			<?php the_posts_navigation(); ?> 
    
                	<?php else :
    
    					get_template_part( 'content', 'none' );
    
                endif; ?>
    
            </main><!-- #main -->
        </div><!-- #primary -->
    
        <?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_category_layout', 'option1' ) ) ) : ?>
    
        <?php else : ?>
    
            </div><!-- col -->
    
            	<?php if ( 'option1' == resi_sanitize_index_content( get_theme_mod( 'resi_category_layout', 'option1' ) ) ) : ?>
    
    			<?php else : ?>
    
        			<?php get_sidebar(); ?> 
    
    			<?php endif; ?>
    
        	</div><!-- grid -->
    
        <?php endif; ?>
    
    <?php get_footer(); ?>
  • The topic ‘Hiding post title in a specific category’ is closed to new replies.