- This topic has 7 replies, 2 voices, and was last updated 9 years, 7 months ago by
Sakin.
-
AuthorPosts
-
February 18, 2014 at 12:29 am #20478
rekkette
MemberHi, 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.
February 18, 2014 at 1:17 am #20482Sakin
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.
February 18, 2014 at 1:34 am #20483rekkette
MemberYou 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.
February 18, 2014 at 1:46 am #20484Sakin
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.
February 18, 2014 at 4:45 am #20489rekkette
MemberOkay, 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?
February 18, 2014 at 9:22 am #20493Sakin
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.
February 19, 2014 at 1:01 am #20503rekkette
MemberI 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!
February 19, 2014 at 11:40 am #20521 -
AuthorPosts
- The topic ‘Would like to add category.php and tag.php’ is closed to new replies.