Support » Plugins » I am stuck with categories, Need your help. Urgent!

  • I would like to display different number of post in different categories. My current code on category.php is

    [B]<?php if ( is_category(array(2,37)) )
    {
    include(TEMPLATEPATH . ‘/category1.php’);
    }
    else
    {
    include(TEMPLATEPATH . ‘/archive.php’);
    }
    ?>[/B]

    All i want to do is integrate the code below with category1 above, but do not how to do it.

    [B]<?php query_posts(‘category_name=special_cat&showposts=10’); ?>[/B]

    help highly appreciated.

    nirav

Viewing 7 replies - 1 through 7 (of 7 total)
  • You mean like this?

    <?php if ( is_category(array(2,37)) )
    {
    include(TEMPLATEPATH . '/category1.php');
    $showposts=10;
    }
    else
    {
    include(TEMPLATEPATH . '/archive.php');
    $showposts=6;
    }
    ?>
    
    <?php query_posts('category_name=special_cat&showposts=$showposts'); ?>

    Also review the information in Template Hierarchy, in particular those having to do with categories and Category Templates.

    Thread Starter niravdave

    (@niravdave)

    Hey MichaelH,

    Thanks for your response. I tried to use this code on category.php but that did not change anything. I did refer to the Category template link earlier, but have no idea how do i exactly achieve this.

    cheers!

    `<?php if ( is_category(array(2,37)) )
    {
    include(TEMPLATEPATH . ‘/category1.php’);
    $showposts=10;
    }
    else
    {
    include(TEMPLATEPATH . ‘/archive.php’);
    $showposts=6;
    }
    ?>

    Ah that line

    <?php if ( is_category(array(2,37)) )

    should be:

    <?php if ( is_category(2) || is_category(37) )

    Thread Starter niravdave

    (@niravdave)

    ok MichaelH

    As per your suggestion now i m using the code below. But Did not help. I hope i have been clear on explaining on what I am trying to acheive here.

    In simple words.

    Category 2 and 37: i want to display 20 posts and
    Other Catgories: I want to display 6 posts.

    <?php if ( is_category(2) || is_category(37) )
    {
    include(TEMPLATEPATH . ‘/category1.php’);
    $showposts=20;
    }
    else
    {
    include(TEMPLATEPATH . ‘/archive.php’);
    $showposts=6;
    }
    ?>

    Make your query_posts be

    query_posts($query_string . "&showposts=$showposts");

    You shouldn’t need the category_name=special_cat cause the query will already have the category you need.

    Thread Starter niravdave

    (@niravdave)

    sorry, i m not a php expert so do not follow what you are saying.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I am stuck with categories, Need your help. Urgent!’ is closed to new replies.