Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Mahesh 3 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #95181

    aparente001
    Participant

    I created a category archive page in my main menu (for category = ‘question’). I would like to achieve the following:

    – change the way the page title appears

    – display the full content of each post in this category (not an excerpt)

    – display all the comments, without requiring the visitor to click on anything

    – display only the 50 most recent posts in this category

    Here’s how I tried to do this. I copied the file category.php from the Catch Evolution folder over to the child theme folder. I changed the file name to category-question.php. I edited the file and changed the printf line to read as follows:

    printf( __( 'HELPline Test');

    I added the following right before the endwhile:

    <?php comments_template( '', true ); ?>

    However, the page no longer loads. It used to, before I copied the file over to the child theme folder, and edited it.

    I read, but did not understand, the instructions in category.php that read as follows:

    /* Include the Post-Format-specific template for the content.
     * If you want to overload this in a child theme then include a file
     * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */

    Hoping for some guidance about this, and also limiting the number of posts to 50. Thank you.

    #95218

    Mahesh
    Keymaster

    @aparante001: Please replace the code in your child theme’s category.php with the code below:

    <?php
    /**
     * The template for displaying Category Archive pages.
     *
     * @package Catch Themes
     * @subpackage Catch_Evolution_Pro
     * @since Catch Evolution 1.0
     */
    
    get_header(); ?>
    
    			<?php if ( have_posts() ) : ?>
    
    				<header class="page-header">
    					<h1 class="page-title"><?php
    						printf( __( 'HELPline Test', 'catch-evolution' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    					?></h1>
    
    					<?php
    						$category_description = category_description();
    						if ( ! empty( $category_description ) )
    							echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
    					?>
    				</header>
    
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    					?>
    
    					<?php
    						$withcomments = "1";
    						comments_template( '', true );
    					?>
    
    				<?php endwhile; ?>
    
    				<?php catchevolution_content_nav( 'nav-below' ); ?>
    
    			<?php else : ?>
    
    				<article id="post-0" class="post no-results not-found">
    					<header class="entry-header">
    						<h1 class="entry-title"><?php _e( 'Nothing Found', 'catch-evolution' ); ?></h1>
    					</header><!-- .entry-header -->
    
    					<div class="entry-content">
    						<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'catch-evolution' ); ?></p>
    						<?php get_search_form(); ?>
    					</div><!-- .entry-content -->
    				</article><!-- #post-0 -->
    
    			<?php endif; ?>
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer();

    This will resolve two of your issues.
    – change the way the page title appears
    – display all the comments, without requiring the visitor to click on anything

    For the other two, you’ll have to change some settings. Please follow along:
    – display the full content of each post in this category (not an excerpt)
    Go to Dashboard=> Appearance=> Customize=> Theme Options=> Layout Options and select Full Content Display in Full Content Display and click on Save Changes

    – display only the 50 most recent posts in this category
    Go to Dashboard=> Settings=> Reading and put 50 in Blog pages show at most field and click on Save Changes

    Hope this helps. Let me know if any problem.

    Regards,
    Mahesh

    #95231

    aparente001
    Participant

    Thank you, but I have other archive pages where I need category.php to be unaltered. It’s just for this one category (=question) where things should behave differently.

    I tried your code in a file (in the child theme directory) called category-question.php. Using this to create a category page gave me an error as follows:

    The main page isn’t working
    
    

    Site is currently unable to handle this request.
    HTTP ERROR 500

    #95237

    Mahesh
    Keymaster

    @aparente001: The code should have worked fine. I have attached the category-question.php file in the link below, please try and check if this helps. I checked it in our server and worked fine.
    https://goo.gl/bPliQa
    Let me know if any problem.

    Regards,
    Mahesh

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘category archive’ is closed to new replies.