how to display one category of posts on the main page

0 views
Skip to first unread message

assistedsu...@gmail.com

unread,
Jan 1, 2010, 6:55:07 PM1/1/10
to K2 Support
Hi,
I have 2 categories. One of those categories I keep posts in that I do
not wish to be displayed on the main "blog" page of the website.
However despite having the posts I want viewable on the main page in
their own category and the posts in another category, the main page
still keeps displaying ALL posts.
How do I stop the main page/blog showing ALL of the posts? I just want
to show posts in one category.
Thanks,
Leanne

Scot

unread,
Jan 2, 2010, 2:09:42 PM1/2/10
to K2 Support
you can create a home.php page and add this part to the coding.
make sure you set the h2 to your category title and you must use this
plugin to get this to work.
http://labitacora.net/comunBlog/limit-post.phps take this copy to
notepad save it as limit-post.php upload to your plugin folder.
remember if you dont use this template anymore turn it off it might
cause a error with other templates.

it will limit the amount of text to be displayed on the front page.
also will display a thumbnail beside the image.
so go to post and add Thumbnail to custom field name then the link to
the image for the value then update button


next you see cat=3 that is the category id number and showposts=3 it
will display 3 post from that category. you can repeat this block as
many times as you want for each category's that you have.
I dont know how to make this a add on for the k2 so you will have to
do a small amount of coding to get this to work... just remember to
take your index.php and cut out all the coding
starting with <?php /* K2 Hook */
to
<?php /* K2 Hook */
then take this code and paste it where the old code was.


<h2>Local News</h2>
<?php $recent = new WP_Query("cat=3&showposts=3"); while($recent-
>have_posts()) : $recent->the_post();?>
<?php if( get_post_meta($post->ID, "Thumbnail", true) ): ?>
<img style="float:left;margin:5px 5px 10px 0px;width:
70px;height:70px" src="<?php echo get_post_meta($post->ID,
"Thumbnail", true); ?>" alt="alt text" />
<?php else: ?>
<img style="float:left;margin:5px 5px 10px 0px;width:
70px;height:70px" src="<?php bloginfo('template_url'); ?>/images/
thumbnail.jpg" alt="Default Thumbnail" />
<?php endif; ?>
<b><?php the_title(); ?></b>
<?php the_content_limit(125, ""); ?>
<p><b><?php the_time('F j, Y'); ?></b> | <a href="<?
php the_permalink() ?>" rel="bookmark">Read the story &raquo;</a></p>
<div style="border-bottom:1px dotted #C0C0C0; margin-bottom:10px;
padding:0px 0px 10px 0px; clear:both;"></div>
<?php endwhile; ?><br />

i hoped i have helped.. i have a demo site so you can see the
example. I'm not using the k2 theme but you can see what i have did..
http://huntsvillerocket.com/

Scot

Reply all
Reply to author
Forward
0 new messages