WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display only the title in categories (15 posts)

  1. agonche
    Member
    Posted 1 year ago #

    I am using Twenty Twelve theme.

    When a user clicks on a category, I want the website to show only post titles, not the content (whole post).
    How do I do that ? What to edit ?

  2. Kegan Quimby
    Member
    Posted 1 year ago #

    If you go to Appearance > Editor and edit the archives.php file, you can pull out the line that says <?php the_content(); ?> or <?php the_excerpt(); ?>

  3. agonche
    Member
    Posted 1 year ago #

    I am using WordPress 3.4.2 and Twenty Twelve theme.
    There isn't a line that says <?php the_content(); ?> or <?php the_excerpt(); ?>

    Maybe that method works in older versions or different themes.

    Here is my archive.php file.

    <?php
    /**
     * The template for displaying Archive pages.
     *
     * Used to display archive-type pages if nothing more specific matches a query.
     * For example, puts together date-based pages if no date.php file exists.
     *
     * If you'd like to further customize these archive views, you may create a
     * new template file for each specific one. For example, Twenty Twelve already
     * has tag.php for Tag archives, category.php for Category archives, and
     * author.php for Author archives.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    		<?php if ( have_posts() ) : ?>
    			<header class="archive-header">
    				<h1 class="archive-title"><?php
    					if ( is_day() ) :
    						printf( __( 'Daily Archives: %s', 'twentytwelve' ), '<span>' . get_the_date() . '</span>' );
    					elseif ( is_month() ) :
    						printf( __( 'Monthly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentytwelve' ) ) . '</span>' );
    					elseif ( is_year() ) :
    						printf( __( 'Yearly Archives: %s', 'twentytwelve' ), '<span>' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentytwelve' ) ) . '</span>' );
    					else :
    						_e( 'Archives', 'twentytwelve' );
    					endif;
    				?></h1>
    			</header><!-- .archive-header -->
    
    			<?php
    			/* Start the Loop */
    			while ( have_posts() ) : the_content();
    
    				/* Include the post format-specific template for the content. If you want to
    				 * this in a child theme then include a file called called content-___.php
    				 * (where ___ is the post format) and that will be used instead.
    				 */
    				get_template_part( 'content', get_post_format() );
    
    			endwhile;
    
    			twentytwelve_content_nav( 'nav-below' );
    			?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    
    		</div><!-- #content -->
    	</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
  4. agonche
    Member
    Posted 1 year ago #

    or maybe I should edit the Category Template (category.php) file ?

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    Do not edit the Twenty Twelve theme. It is will be the default theme in WordPress 3.5 and having access to an unedited version of the theme is vital when dealing with a range of site issues. First create a child theme for your changes.

  6. agonche
    Member
    Posted 1 year ago #

    Okay, thanks for the tip, but you didn't answer my question
    Anyone else ?

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    Have you created a child theme yet?

  8. agonche
    Member
    Posted 1 year ago #

    Yes sir.

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    Create a copy of the parent's content.php template in the child theme and then edit this copy. Replace:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

    with:

    <?php if ( is_search() || is_category() ) : ?>

  10. agonche
    Member
    Posted 1 year ago #

    Almost there.
    I want just the title of the post, not the excerpt.

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    In that case, remove:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<?php endif; ?>
  12. esmi
    Forum Moderator
    Posted 1 year ago #

    Sorry - scratch that. I'm not thinking straight. Replace:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    with:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php elseif( !is_category() ) : ?>
    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>
  13. ruudvandemolen
    Member
    Posted 1 year ago #

    This worked for me, thanks.

  14. DhanyaAbraham
    Member
    Posted 9 months ago #

    Hi
    I am using a grid like structure for my front page.It will show only th featured images of the posts. I need only its category tile to be displayed on the top of the image. How to do it?

  15. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    @DhanyaAbraham - please start your own thread and include more info in your post -

    http://codex.wordpress.org/Forum_Welcome#Where_To_Post

    http://codex.wordpress.org/Forum_Welcome#Include_as_much_information_as_possible

    This thread is marked resolved and quite out of date.

Topic Closed

This topic has been closed to new replies.

About this Topic