WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Modifying CSS Categories to show Excerpts (12 posts)

  1. lynchd57
    Member
    Posted 1 year ago #

    Hi there,
    does anybody know a CSS code to put in for making the categories show excerpts instead of full posts in the bootstrap theme. When you click on a category it displays the full posts instead of just an excerpt of each post, it takes forever scrolling through them for visitors. Any help with a code to put in my CSS editor would be appreciated.

    Lynchd57

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    That won't be CSS. It will be PHP. Try editing the relevant template file and replacing <?php the_content();?> with <?php the_excerpt();?>. If you don't know which file to edit, have a look at Theme Development.

  3. lynchd57
    Member
    Posted 1 year ago #

    Hi there,
    This is the category PHP template which part of this code do l edit,

    get_header(); ?>
    
    <section id="primary" class="span8">
    
        <?php tha_content_before(); ?>
        <div id="content" role="main">
            <?php tha_content_top();
    
            if ( have_posts() ) : ?>
    
                <header class="page-header">
                    <h1 class="page-title"><?php
                        printf( __( 'Category Archives: %s', 'the-bootstrap' ), '<span>' . single_cat_title( '', false ) . '</span>' );
                    ?></h1>
    
                    <?php if ( $category_description = category_description() ) {
                        echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
                    } ?>
                </header><!-- .page-header -->
    
                <?php
                while ( have_posts() ) {
                    the_post();
                    get_template_part( '/partials/content', get_post_format() );
                }
                the_bootstrap_content_nav();
            else :
                get_template_part( '/partials/content', 'not-found' );
            endif;
    
            tha_content_bottom(); ?>
        </div><!-- #content -->
        <?php tha_content_after(); ?>
    </section><!-- #primary -->
    
    <?php
    get_sidebar();
    get_footer();

    Really appreciate your help.

    Dave

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Try looking in /partials/content-standard.php or /partials/content.php

  5. lynchd57
    Member
    Posted 1 year ago #

    Hi there esmi,
    l found this one content php

    just tell me where l need to edit

    * The default template for displaying content
     *
     * @author		Konstantin Obenland
     * @package		The Bootstrap
     * @since		1.0.0 - 05.02.2012
     */
    
    tha_entry_before(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php tha_entry_top(); ?>
    
    	<header class="page-header">
    	<?php if ( is_sticky() AND is_home() ) : ?>
    		<hgroup>
    			<?php the_title( '<h1 class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', 'the-bootstrap' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">', '</a></h1>' ); ?>
    			<h3 class="entry-format"><?php _e( 'Featured', 'the-bootstrap' ); ?></h3>
    		</hgroup>
    	<?php
    		else :
    			the_title( '<h1 class="entry-title"><a href="' . get_permalink() .'" title="' . sprintf( esc_attr__( 'Permalink to %s', 'the-bootstrap' ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark">', '</a></h1>' );
    		endif;
    
    		if ( 'post' == get_post_type() ) : ?>
    		<div class="entry-meta">
    			<?php the_bootstrap_posted_on(); ?>
    		</div><!-- .entry-meta -->
    		<?php endif; ?>
    	</header><!-- .entry-header -->
    
    	<?php if ( is_search() ) : // Only display Excerpts for Search ?>
    	<div class="entry-summary clearfix">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php else : ?>
    	<div class="entry-content clearfix">
    		<?php if ( has_post_thumbnail() ) : ?>
    		<a>" title="<?php the_title_attribute(); ?>">
    			<?php the_post_thumbnail( 'thumbnail' ); ?>
    		</a>
    		<?php endif;
    		the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'the-bootstrap' ) );
    		the_bootstrap_link_pages(); ?>
    	</div><!-- .entry-content -->
    	<?php endif; ?>
    
    	<footer class="entry-meta">
    		<?php
    		$categories_list = get_the_category_list( _x( ', ', 'used between list items, there is a space after the comma', 'the-bootstrap' ) );
    
    		if ( 'post' == get_post_type() AND $categories_list ) // Hide category text for pages on Search
    			printf( '<span class="cat-links block">' . __( 'Posted in %1$s.', 'the-bootstrap' ) . '</span>', $categories_list );
    		?>
    	</footer><!-- #entry-meta -->
    
    	<?php tha_entry_bottom(); ?>
    </article><!-- #post-<?php the_ID(); ?> -->
    <?php tha_entry_after();
    
    /* End of file content.php */
    /* Location: ./wp-content/themes/the-bootstrap/partials/content.php */

    Thanks very much if you can help

    Dave

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code has been permanently damaged/corrupted by the forum's parser.]

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    Replace <?php the_excerpt(); ?> with <?php the_content(); ?>.

  7. lynchd57
    Member
    Posted 1 year ago #

    Hi esmi,
    thank you very much job done.

    Cheers
    david

  8. turntothewright
    Member
    Posted 1 year ago #

    Hi esmi,
    I am trying to fix my excerpts option in 3.4.2. I looked at all the above information, but don't see which file in the c-panel this code is contained.
    BTW, I got the RSS fixed! Thanks!

  9. lynchd57
    Member
    Posted 1 year ago #

    done

  10. turntothewright
    Member
    Posted 1 year ago #

    did you intend the "done" post for me, luynchd57, or for esmi?

  11. lynchd57
    Member
    Posted 1 year ago #

    It was just l am finished with the post. if your directing that questions towards me and my problem, mine was in the bootstrap theme and l was having trouble with categories showing full posts instead of excerpts. I found the file its was under edit content php file this the part of the file you have to change to excerpt, you can see where l put excerpts in.

    <?php endif;
    the_excerpt( __( 'Continue reading <span class="meta-nav">→</span>', 'the-bootstrap' ) );
    the_bootstrap_link_pages(); ?>
    </div><!-- .entry-excerpt -->
    <?php endif; ?>

    goodluck
    lynchd57

  12. turntothewright
    Member
    Posted 1 year ago #

    Thanks, lynchD57.
    My issue wasn't exactly what yours was (I don't know what a "bootstrap" is), but it lead me to use some different keywords in my search in the forum. Woo-hoo! Now it works. Thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic