WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Assigning singular one-column template to Category Archive template (3 posts)

  1. databell96
    Member
    Posted 1 year ago #

    I'm trying to create a category archive template for this page using category-xxx.php for my template. For the most part I got it, but here's the issue at hand. Unlike my standard category template, which is two column and has a sidebar, I have one column and no sidebar and it's tricky to get it just right using the standard Twenty Eleven CSS, of which my theme is based upon. I know items like singular and one column appear in the body tag, so how do I make it where for this template only, I can register it as one column so my primary div is 100%?

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

    find this in functions.php of your cloned theme, possibly near the end
    (that is where the .singular body_class gets added):

    /**
     * Adds two classes to the array of body classes.
     * The first is if the site has only had one author with published posts.
     * The second is if a singular post being displayed
     *
     * @since Twenty Eleven 1.0
     */
    function twentyeleven_body_classes( $classes ) {
    
    	if ( function_exists( 'is_multi_author' ) && ! is_multi_author() )
    		$classes[] = 'single-author';
    
    	if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) )
    		$classes[] = 'singular';
    
    	return $classes;
    }
    add_filter( 'body_class', 'twentyeleven_body_classes' );

    change the one line to include your category-xxx template:

    if ( is_singular() && ! is_home() && ! is_page_template( 'showcase.php' ) && ! is_page_template( 'sidebar-page.php' ) || is_category('xxx') )

    http://codex.wordpress.org/Function_Reference/is_category

    (untested)

  3. databell96
    Member
    Posted 1 year ago #

    Sorry for the delay in getting back to you on this, but the site in question had server issues most of the day. That did work so thanks for helping me out with that.

Topic Closed

This topic has been closed to new replies.

About this Topic