WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How To Remove "Category Archives" Using A Child Theme (7 posts)

  1. bsjoseph
    Member
    Posted 1 year ago #

    I have my blog set-up so that a category must be selected. I don't mind if the header reads the category but I would like to remove the "Category Archive:" part. I am using Twentytwelve theme. Please tell me what I need to name the child theme .php file, as well as the code I need to insert inside of the .php file to hide/remove this text.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    create a copy of category.php in the child theme, and edit - what to edit is quite obvious.

  3. bsjoseph
    Member
    Posted 1 year ago #

    If I delete "Category Archives: %s" then it removes the whole thing. I want it to display the category, but not display "Category Archives" (see code below).

    <?php
    /**
     * The template for displaying Category pages.
     *
     * Used to display archive-type pages for posts in a category.
     *
     * 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 printf( __( 'Category Archives: %s', 'twentytwelve' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
    
    			<?php if ( category_description() ) : // Show an optional category description ?>
    				<div class="archive-meta"><?php echo category_description(); ?></div>
    			<?php endif; ?>
    			</header><!-- .archive-header -->
    
    			<?php
    			/* Start the Loop */
    			while ( have_posts() ) : the_post();
    
    				/* 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. bsjoseph
    Member
    Posted 1 year ago #

    Never mind. I figured it out. Just needed to leave in the "%s" only.

  5. annischke
    Member
    Posted 8 months ago #

    Hi all,

    I've the same problem as bsjoseph but could not find the code in the .php leading me to what is 'category archive' and what is 'name of category' as both (concerning my theme) seem to be express by '%s". (So deleting them makes both disappear, deleting one means deleting 'name of category') What I want is deleting 'category archives' and only 'name of category' to be shown.

    Here's the part of my archive.php:

    h1 class="page-title">
    
    					<?php
    					if ( is_category() ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'category', get_queried_object()->slug ) . '</span>', single_cat_title( '', false ) );
    					} elseif ( is_tag() ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'tag', get_queried_object()->slug ) . '</span>', single_tag_title( '', false ) );
    
    					} elseif ( is_author() ) {
    						/* Queue the first post, that way we know
    						 * what author we're dealing with (if that is the case).
    						*/
    						the_post();
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'author', get_the_author_meta( 'user_nicename' ) ) . '</span>',
    							sprintf( '<span class="vcard"><a class="url fn n" href="%s" title="%s" rel="me">%s</a></span>',
    								esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    								esc_attr( get_the_author() ),
    								esc_html( get_the_author() )
    							)
    						);
    						/* Since we called the_post() above, we need to
    						 * rewind the loop back to the beginning that way
    						 * we can run the loop properly, in full.
    						 */
    						rewind_posts();
    
    					} elseif ( is_day() ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'day', get_the_date( 'Y-m-d' ) ) . '</span>', get_the_date() );
    
    					} elseif ( is_month() ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'month', get_the_date( 'Y-m' ) ) . '</span>', get_the_date( 'F Y' ) );
    
    					} elseif ( is_year() ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'year', get_the_date( 'Y' ) ) . '</span>', get_the_date( 'Y' ) );
    
    					} elseif ( is_tax( 'post_format' ) ) {
    						printf( '%s %s', '<span>' . blocco_archive_title_descriptor( 'post-format', get_post_format() ) . '</span>', blocco_post_format_label() );
    
    					} else {
    						print blocco_archive_title_descriptor( 'post-type', get_post_type() );
    					}
    					?>
    
    				</h1><!-- .page-title -->
    			</header> <!-- .page-header -->
    
    			<?php while ( have_posts() ) : the_post(); ?>

    I guess line 3 is the important part?

    I'm thankful for any advice!

  6. WPyogi
    Volunteer Moderator
    Posted 8 months ago #

    @annischke - this thread is marked resolved - please start your own thread per the forum guidelines -

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

  7. annischke
    Member
    Posted 8 months ago #

    Ups - thanks for the hint

Topic Closed

This topic has been closed to new replies.

About this Topic