Hi I need some help I have a list of posts on my wordpress category page and I would like to set first few to have a different background, only on the category page. That way when visitor would click on the category and see 10 posts, the first two for example would have a different styling. It would be really cool if I could somehow set this to happen in only few categories. Is there a plugin or function to do that? Thank you very much for your help in advance.
Depending on the theme you are using, this functionality should be built into it already. When you mark a post as a "sticky" it should float to the top of the page. Review your source code to see what you will need to style with CSS, if needed.
Nothing happens. I'm talking about the category pages. Not the front page, if that makes a difference. Or is there any way to just change the look of the post? I could bring it up by changing the date...
Look at the coding for the front page, then modify your categories.php file to do the same thing. Styling to make them look different is easy too, but would again depend upon the theme. You need to look at your source code to see what class they identify sticky post with (usually this is just "sticky"). With that information you will be able to apply styling in your theme stylesheet.
Thank you very much for trying to help me out Dodger. I just can't manage to get any style to the posts in the category. This is what I use in the category page to call posts: after that is the post definiton. How could I get wp to add some styling in case post is a sticky? thanks alot again!
You left out the most important part, all of the stuff that displays the post. Post the whole categories.php file. And it would be helpful if you posted it within the bbCode "code" tags to make it easier to read and maintain the formatting.
BTW, is this your theme? http://code.google.com/p/narutowarmanager/source/browse/nwm_web/exehill2/?r=3
no, I'm using benzo theme I am adding the full category page below. I managed to partly solve the problem though. I added this as a class of a post holder on the category page: <?php if (is_sticky()) echo 'class="sticky"'; else echo 'class="normal"'; ?> Code (markup): So that part is solved. Now I just have to find a way to bring all the sticky posts from a certain category to the top of the category page. Any help will be greatly appriciated. Thank you very much Dodger! Category page: <?php global $options; foreach ($options as $value) {if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }}?> <?php get_header(); ?> <div class="cat_container"> <div class="cat_left"> <?php while (have_posts()) : the_post(); ?> <?php if ($images = get_children(array( 'post_parent' => $post->ID, 'numberposts' => '1', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order'))) foreach($images as $image) { $exehill_image = $image->guid; $exehill_thumb = wp_get_attachment_thumb_url( $image->ID); } else { $exehill_thumb = site_url('/wp-content/themes/benzo1.1/images/noimage_cat.png'); } ?> <div class="blog_container"> <div class="blog_top" style="background: url(<?php echo $exehill_thumb; ?>) no-repeat; "> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"></a> </div> <div class="blog_content"> <div class="blog_headline"> <span class="blog_title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></span> </div> <div class="blog_excerpt"><?php the_excerpt(); ?><span><a href="<?php the_permalink() ?>">Learn more →</a></span> </div> </div> <div class="clear"> </div> </div> <?php endwhile; ?> <div class="pagnav"> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> </div> </div> <div class="cat_right"><?php get_sidebar(); ?> </div> <div class="clear"> </div> </div> <?php get_footer(); ?> Code (markup):
Technically, you will need two WP_Query Loops that take advantage of Sticky Post Parameters. First loop will display 'x' amount of sticky posts, then the second will display 'x' amount of non-sticky posts. Currently you have one loop that displays all posts in the category without separation. Separating into two Loops, of which, both will look almost identical line for line except the parameters for whether they are sticky or not. This is not just a simple cut and paste also, you need to have two WP_Query objects created (the first is already there via the global $post which has the have_posts() and the_post() methods in play). Since there will be repetitive code, consolidating all of the code that outputs 'blog_container' DIV block into a callable function would be prudent also. That is the theory anyway. Between the two links I gave you above, you should be able to muddle through this. As an aside, for a premium theme, I am not too impressed with the coding I have seen (that Google code link I asked about uses parts of your theme, or is a pre-cursor to it )
Thanks alot Dodger! I will read it all through the moment I have a little more time. Otherwise I'll just use dates to get them up on the top thank you again for your help