Tagged: ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #20478
    rekkette
    Member

    Hi, I would like to add further formatting. Specifically, I’d like to create a category.php and a tag.php.

    I would like then to use these templates to format the pages differently.

    How would I add these into the theme? To which file would I add the call for the specific template? I do not see a specific template that governs either category or tags, so I don’t know how to call these templates.

    #20482
    Sakin
    Keymaster

    @rekkette: Looks like you want to do advance customization, then you need to build child theme and then add your own copy tag.php, category.php and so on.

    #20483
    rekkette
    Member

    You are absolutely correct. That IS what I am already doing.
    I do need a little bit of assistance, though.

    Okay, so I found where I would link it in – via the Archives.php

    Line 21-24 seems to have the relevant info on category and tags.

    Am I correct in thinking that this is where I would put a get_templat_part code?

    Sorry, I’m actually not very good at php, that’s why I gotta ask…

    BTW, really thank you for taking the time to answer this. I do appreciate it.

    #20484
    Sakin
    Keymaster

    @rekkette: Yes, you are right line no 21 to 26 is about category and tag title

    
    //This is for Category and Tag Titles line no 21 to 26
    if ( is_category() ) {
        printf( __( 'Category Archives: %s', 'catcheverest' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    
    } elseif ( is_tag() ) {
        printf( __( 'Tag Archives: %s', 'catcheverest' ), '<span>' . single_tag_title( '', false ) . '</span>' );
    
    }
    
    //This is for category and tag description line no 55 to 66 
    if ( is_category() ) {
        // show an optional category description
        $category_description = category_description();
        if ( ! empty( $category_description ) )
            echo apply_filters( 'category_archive_meta', '<div class="taxonomy-description">' . $category_description . '</div>' );
    
    } elseif ( is_tag() ) {
        // show an optional tag description
        $tag_description = tag_description();
        if ( ! empty( $tag_description ) )
            echo apply_filters( 'tag_archive_meta', '<div class="taxonomy-description">' . $tag_description . '</div>' );
    }
    
    // For content you need to play with the code in line no 75 to 81
    <?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() );
    ?>

    If this is complicated for you then you can simply create category.php file to control category display and similarly create tag.php file to control tag.

    So now you have 2 options and you can work in any one in which you feel comfortable in.

    #20489
    rekkette
    Member

    Okay, I think I understand.

    In lines 75-81, I can either write my category/tag-specific formatting right in there, or I can call my template parts category.php or tag.php

    And of course, I’d have to use the correct conditional tags.

    Am I getting it?

    #20493
    Sakin
    Keymaster

    @rekkette: Yes you are write about lines 75-81. But category.php and tag.php in not a template part. But it’s a full new template which will overwrite archives.php code.

    #20503
    rekkette
    Member

    I got it working! Thank you so much for walking me through this! I’ll get it eventually. I think I’m finally starting to understand the structure thanks to you!

    #20521
    Sakin
    Keymaster

    @rekkette: that’s great. 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Would like to add category.php and tag.php’ is closed to new replies.