Forums

[resolved] Different layout for page if certain category (7 posts)

  1. callender
    Member
    Posted 1 year ago #

    Hi all,

    How do i tell wordpress to format a page differently if i am using a certain category..

    eg: if cat15 use category-images.php

    Thank you!

    Jim C.

  2. Jackson
    Member
    Posted 1 year ago #

    Either via category templates:

    See: http://codex.wordpress.org/Category_Templates

    Or you could also use the body_class function:

    See: http://codex.wordpress.org/Template_Tags/body_class

  3. callender
    Member
    Posted 1 year ago #

    thats great thank you madjax..

  4. callender
    Member
    Posted 1 year ago #

    Madjax,

    Do you know how I would tell wordpress the following:

    Display normal category layout, unless on certain category, eg: video, then deliver a different layout, eg: thumbnails only..

    This will be contained in the category loop, any examples would be great. I am not an expert php coder.

    Thank you!

    J

  5. MAS
    Member
    Posted 1 year ago #

    Use conditions like

    if (in_category('video')) :

    //put the code here for video according your design.

    else
    //put the code here according your design.
    endif;

  6. callender
    Member
    Posted 1 year ago #

    Many thanks Chinmoy!

    I'm not sure my code is correct - coul you just check my code, in particular the PHP syntax:

    // The Category Loop
    function thematic_category_loop() {
    		while (have_posts()) : the_post(); ?>
    
    	<?php if(in_category('17') ) : ?>
    
    		<!-- layout #1 --> 
    
    	<?php if( in_category( array( 19,20 ) ) : ?>
    
                   <!-- layout #2 -->
    
    	<?php else : ?>
    
                  <!-- default layout -->
    
    	<?php endif; ?>

    Many thanks,

    Jim C

  7. MAS
    Member
    Posted 1 year ago #

    // The Category Loop
    function thematic_category_loop() {
    		while (have_posts()) : the_post(); ?>
    
    	<?php if(in_category('17') ) : ?>
    
    		<!-- layout #1 --> 
    
    	<?php elseif( in_category( array( 19,20 ) ) : ?>
    
                   <!-- layout #2 -->
    
    	<?php else : ?>
    
                  <!-- default layout -->
    
    	<?php endif; ?>
    }?>

Topic Closed

This topic has been closed to new replies.

About this Topic