• This seems like it should be an easy task, but for the life of me I can’t figure it out. I have a site running on WordPress that is using a custom theme; someone else built it and I am not maintaining it.

    I am wanting to link to a page that lists all posts within one certain category, for example: mysite.com/category/my-latest-news. When I go to that URL, it’s correctly pulling in everything I have posted under the category my-latest-news, but there is absolutely no design whatsoever. It’s just a page of links and headers vertically stacking…no CSS or structure to it whatsoever.

    My question is: How do I apply my theme to that one page?

Viewing 9 replies - 1 through 9 (of 9 total)
  • It should be applied automatically. As it’s not, this suggests that there is a deeper problem with the theme.

    Thread Starter megmo

    (@megmo)

    But what about when it’s a custom theme? I can see in the various templates where the stylesheet is being called, but I don’t see it in category.php. Do I need to edit that template to call in the stylesheet?

    But what about when it’s a custom theme?

    Do you mean a custom page template? Even then, the page template should be using the same header.php file and the same CSS.

    Thread Starter megmo

    (@megmo)

    I guess? All I know is the theme was developed by their IT department and they are not using a WordPress theme that someone else created.

    When you say the template page should be using the same header.php file and the same CSS, how do I make sure that it is?

    For example, in a page template, which does display correctly, I see this;

    <head><meta charset="<?php bloginfo( 'charset' ); ?>" />
    <title>Title here</title>
    //Some other info here
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/style.css" />

    But in the category template, I don’t have that. I just see this:

    get_header(); ?>

    And then some other code that has to do with the category description, etc.

    Do I need to bring over the header and CSS code from the Page template?

    For example, in a page template, which does display correctly, I see this

    Oh – they’re using a completely different header in the page templates. That’s messy!

    For now, you’ll need to replicate that entire header section when creating a new page template. In fact, what I would do in your place is copy an existing page template that you know works, save it with a new file name, give a new template name in the comment part at the top of the file and then start editing the rest of the code to suit your purposes.

    Thread Starter megmo

    (@megmo)

    Thanks so much, I was able to get excerpts of the category posts to show up, but now I’m trying to figure out how to edit that down a bit (ie I don’t want to show what each post is tagged with, allow people to comment, etc.) right from the excerpt.

    This is the code that’s pulling in excerpts of each post in the specific category; what are the loops or snippets I should use just to show a headline, excerpt and “continue reading”? I’d also like to keep the “older posts” and “newer posts” links at the top and bottom.

    <h1 class="page-title"><?php
    					printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );
    				?></h1>
    
    				<?php
    					$category_description = category_description();
    					if ( ! empty( $category_description ) )
    						echo '<div class="archive-meta">' . $category_description . '</div>';
    
    				/* Run the loop for the category page to output the posts.
    				 * If you want to overload this in a child theme then include a file
    				 * called loop-category.php and that will be used instead.
    				 */
    				get_template_part( 'loop', 'category' );
    				?>

    You would need to create a new loop template file called loop-category.php and ensure that it only includes the template tags that are appropriate for your needs.

    Thread Starter megmo

    (@megmo)

    Excellent… So would I call the loop template file within the category.php file?

    And is there a place I can look to find all of the template tags that I’d want to use?

    Thanks!!

    So would I call the loop template file within the category.php file?

    It’s already being called by get_template_part( 'loop', 'category' );. If loop-category.php doesn’t exist, WP falls back to the main loop.php file.

    Template_Tags is a fairly comprehensive list of tags.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to apply my custom theme to category archive page?’ is closed to new replies.