Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

need this Autofocus Category Template to show specific category WordPress

  • SOLVED

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() ?>

Answers (4)

2010-07-06

Oleg Butuzov answers:

category-28.php


Oleg Butuzov comments:

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


Mat Green comments:

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?


Oleg Butuzov comments:

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


Mat Green comments:

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


2010-07-06

Utkarsh Kukreti answers:

Replace

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


with

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


Mat Green comments:

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

2010-07-06

Rashad Aliyev answers:

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


Rashad Aliyev comments:

However you can use single post query in your template.

Reference:
[[LINK href="http://codex.wordpress.org/Function_Reference/query_posts"]][[/LINK]]


Rashad Aliyev comments:

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


Mat Green comments:

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


Rashad Aliyev comments:

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,


Rashad Aliyev comments:

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


Rashad Aliyev comments:

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.

2010-07-07

Jignesh Patel answers:

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() ?>


Mat Green comments:

Thanks!
This is going wrong aswell!

I need it to look like

[[LINK href="http://www.pavenhillsculptures.com/?cat=28"]][[/LINK]]

when you click on the Gallery option in the menu.

Your solution looks like this

[[LINK href="http://www.pavenhillsculptures.com/?cat=28"]][[/LINK]]

Cheers
mat


Mat Green comments:

Sorry

ur solution look like

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

When it should look like

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


Jignesh Patel comments:

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