logo

$10
need this Autofocus Category Template to show specific category

Hi
I need this template to show jsut the posts in a category number 28.
Can this be done/
Cheers
Mat


<?php
/*
Template Name: Available
*/
?>

<?php get_header() ?>


<div id="container">
<div id="content">

<div class="comment-count">
<h2 class="page-title"><?php _e('Category Archive:', 'sandbox') ?> <span><?php echo single_cat_title(); ?></span></h2>
</div>
<div class="archive-meta"><?php if ( !(''== category_description()) ) : echo apply_filters('archive_meta', category_description()); endif; ?></div>

<div id="nav-above" class="navigation">
<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'sandbox')) ?></div>
<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'sandbox')) ?></div>
</div>

<?php while ( have_posts() ) : the_post(); ?>

<div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">

<div class="preview">
<div class="entry-date bigdate"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('d M'); ?></abbr></div>
<h2 class="entry-title post-content-title"><a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'sandbox'), the_title_attribute('echo=0') ) ?>" rel="bookmark"><span><?php the_title() ?></span></a></h2>
<div class="entry-content post-content">
<h4><?php the_title() ?></h4>
<p><?php the_excerpt(); ?></p>

<?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'sandbox' ) . '&after=</div>') ?>
</div>
<span class="attach-post-image" style="height:300px;display:block;background:url('<?php the_post_image_url('large'); ?>') center center repeat"> </span>
</div><!-- .preview -->

<div class="entry-meta">
<span class="author vcard"><?php printf(__('By %s', 'sandbox'), '<a class="url fn n" href="'.get_author_link(false, $authordata->ID, $authordata->user_nicename).'" title="' . sprintf(__('View all posts by %s', 'sandbox'), $authordata->display_name) . '">'.get_the_author().'</a>') ?></span>
<br />
<?php if ( $cats_meow = sandbox_cats_meow(', ') ) : /* Returns categories other than the one queried */ ?>
<span class="cat-links"><?php printf(__('Also posted in %s', 'sandbox'), $cats_meow) ?></span>
<br />
<?php endif ?>
<?php the_tags(__('<span class="tag-links">Tagged ', 'sandbox'), ", ", "</span>\n\t\t\t\t\t<br />\n") ?>
<span class="comments-link"><?php comments_popup_link(__('Comments (0)', 'sandbox'), __('Comments (1)', 'sandbox'), __('Comments (%)', 'sandbox')) ?></span>
<?php edit_post_link(__('Edit', 'sandbox'), "\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t<br />\n"); ?>
</div>

</div><!-- .post -->

<?php endwhile ?>

<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'sandbox')) ?></div>
<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'sandbox')) ?></div>
</div>

</div><!-- #content .hfeed -->
</div><!-- #container -->

<?php get_sidebar() ?>
<?php get_footer() ?>

Mat Green | 07/06/10 at 5:42pm | Edit


(4) Possible Answers Submitted...

  • avatar
    Last edited:
    10/10/10
    1:25am
    Oleg Butuzov says:

    category-28.php

    • 07/06/10 5:48pm

      Oleg Butuzov says:

      reference http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/

    • 07/06/10 6:20pm

      Mat Green says:

      Thanks for the swift reply.
      I have a name in the menu called GALLERY which i need to connect to this category-27.php page.
      How do I do that as I thought the only way to do it would be creating a template?

    • 07/06/10 6:24pm

      Oleg Butuzov says:

      use get_category_link($categoryid) to get the link to specific category
      and template (as i describe about with the id ) to retrive info from the category

    • 07/06/10 7:42pm

      Mat Green says:

      I'm sorry i don't understand? Can u help?

    • 07/07/10 1:31am

      Oleg Butuzov says:

      butuzov@made.com.ua

  • avatar
    Last edited:
    10/10/10
    1:25am
    Utkarsh Kukreti says:

    Replace


    <?php while ( have_posts() ) : the_post(); ?>


    with

    <?php
    query_posts('category=5');
    while ( have_posts() ) : the_post(); ?>

    • 07/06/10 6:22pm

      Mat Green says:

      Thanks for the reply.
      It doesn't work i'm afraid.
      It screws up the look of it...

      it should look like

      http://www.pavenhillsculptures.com/?cat=27

  • avatar
    Last edited:
    10/10/10
    1:25am
    Rashad Aliyev says:

    that's very easy. change your template name to category-28.php.

    • 07/06/10 5:53pm

      Rashad Aliyev says:

      However you can use single post query in your template.

      Reference:

    • 07/06/10 5:54pm

      Rashad Aliyev says:

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

    • 07/06/10 8:09pm

      Mat Green says:

      hanks for the reply.
      It doesn't work i'm afraid.
      It screws up the look of it...

      it should look like

      http://www.pavenhillsculptures.com/?cat=27

    • 07/08/10 12:35am

      Rashad Aliyev says:

      When you rename your template name to category-id.php (for example: category-27.php ) That mean wordpress will use this template for your 27th category ID. However if you want to make some special design for your this category you can change your "category-27.php".

      If you need more help: http://codex.wordpress.org/Category_Templates

      If you still have a problem contact with me. I've skype on my informations.

      best regards,

    • 07/08/10 12:39am

      Rashad Aliyev says:

      Take you category-28.php ;) Best regards.

    • 07/08/10 12:41am

      Rashad Aliyev says:

      Put it to your theme directory. If you want to use it for different category then change 28 to what you want. For example: rename it category-31.php . That's mean it'll use for Category id for 31.

      Best regards.

  • avatar
    Last edited:
    10/10/10
    1:25am
    Jignesh Patel says:

    Hello

    Here is the your edited code, which will display the posts just under category having id '28'


    <?php

    /*

    Template Name: Available

    */

    ?>



    <?php get_header() ?>





    <div id="container">

    <div id="content">



    <div class="comment-count">

    <h2 class="page-title"><?php _e('Category Archive:', 'sandbox') ?> <span><?php echo single_cat_title(); ?></span></h2>

    </div>

    <div class="archive-meta"><?php if ( !(''== category_description()) ) : echo apply_filters('archive_meta', category_description()); endif; ?></div>



    <div id="nav-above" class="navigation">

    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'sandbox')) ?></div>

    <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'sandbox')) ?></div>

    </div>


    <?php query_posts('cat=28'); ?>
    <?php while ( have_posts() ) : the_post(); ?>



    <div id="post-<?php the_ID() ?>" class="<?php sandbox_post_class() ?>">



    <div class="preview">

    <div class="entry-date bigdate"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('d M'); ?></abbr></div>

    <h2 class="entry-title post-content-title"><a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'sandbox'), the_title_attribute('echo=0') ) ?>" rel="bookmark"><span><?php the_title() ?></span></a></h2>

    <div class="entry-content post-content">

    <h4><?php the_title() ?></h4>

    <p><?php the_excerpt(); ?></p>



    <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'sandbox' ) . '&after=</div>') ?>

    </div>

    <span class="attach-post-image" style="height:300px;display:block;background:url('<?php the_post_image_url('large'); ?>') center center repeat"> </span>

    </div><!-- .preview -->



    <div class="entry-meta">

    <span class="author vcard"><?php printf(__('By %s', 'sandbox'), '<a class="url fn n" href="'.get_author_link(false, $authordata->ID, $authordata->user_nicename).'" title="' . sprintf(__('View all posts by %s', 'sandbox'), $authordata->display_name) . '">'.get_the_author().'</a>') ?></span>

    <br />

    <?php if ( $cats_meow = sandbox_cats_meow(', ') ) : /* Returns categories other than the one queried */ ?>

    <span class="cat-links"><?php printf(__('Also posted in %s', 'sandbox'), $cats_meow) ?></span>

    <br />

    <?php endif ?>

    <?php the_tags(__('<span class="tag-links">Tagged ', 'sandbox'), ", ", "</span>\n\t\t\t\t\t<br />\n") ?>

    <span class="comments-link"><?php comments_popup_link(__('Comments (0)', 'sandbox'), __('Comments (1)', 'sandbox'), __('Comments (%)', 'sandbox')) ?></span>

    <?php edit_post_link(__('Edit', 'sandbox'), "\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t<br />\n"); ?>

    </div>



    </div><!-- .post -->



    <?php endwhile ?>



    <div id="nav-below" class="navigation">

    <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">«</span> Older posts', 'sandbox')) ?></div>

    <div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">»</span>', 'sandbox')) ?></div>

    </div>



    </div><!-- #content .hfeed -->

    </div><!-- #container -->



    <?php get_sidebar() ?>

    <?php get_footer() ?>

    Previous versions of this answer: 07/07/10 at 1:15am | 07/07/10 at 1:15am | 07/07/10 at 1:16am

    • 07/07/10 9:32am

      Mat Green says:

      Thanks!
      This is going wrong aswell!

      I need it to look like



      when you click on the Gallery option in the menu.

      Your solution looks like this



      Cheers
      mat

    • 07/07/10 9:34am

      Mat Green says:

      Sorry

      ur solution look like

      http://www.pavenhillsculptures.com/?page_id=1183

      When it should look like

      http://www.pavenhillsculptures.com/?cat=28

    • 07/07/10 12:58pm

      Jignesh Patel says:

      Mat,

      If you want to have the layout should look like http://www.pavenhillsculptures.com/?cat=28, then plz identify the template (.php file in theme directory) which is used for that & provide that source only.

      It seems the template code you have given above is different (is of http://www.pavenhillsculptures.com/?page_id=1183)

      Thanks

This question has expired.





Current status of this question: Completed