Monday, 15 March 2010

Custom first post on home page wordpress -


I need to change this code, so the first post is displayed with "first" category and firstly There is also a square. The rest of the pages inside, such as Pages / 2 /, Pages / 3 / and so on, will not need this class. I have tried many things, please do not make sure what is wrong here.

  & lt ;? Php if (is_posts ()): $ count = 0; While (is_pause ()): the_post (); If (get_post_type () == 'post'):? & Gt; & Lt ;? Php if (! Is_single () & amp; amp; amp; $ count == 0) :? & Gt; & Lt; Div class = "first aid"? Php echo! Is_home ()? " Notep ":" "? & Gt;" & Gt; & Lt; / Div & gt; & Lt ;? Php endif; ? & Gt; & Lt; Article class = "post  Read & amp; nbsp; more ... & lt; / span & gt;'); ? & Gt; & Lt; / Div & gt; & Lt ;? Includes Php ('post-info.php'); ? & Gt; & Lt; / Article & gt; & Lt ;? Php if (! Is_single () & amp; amp; amp; $ count == 0) :? & Gt; & Lt; Div class = "firstbottom" php echo! Is_home ()? " Nobottom ":" "? & Gt;" & Gt; & Lt; / Div & gt; & Lt ;? Php endif; ? & Gt; & Lt ;? Php endif; $ Count ++; Endwhile; end if; ? & Gt;    

Have you tried using a filter for it?

Read more about WordPress add_filter

You can create a new plugin or add it to your works.php file in your theme directory.

This guy did this with a post-class, but if you do not use post-class in your post loop page, it will not work for you.

Here's a snippet of code:

  add_filter ('post_class', 'wps_first_post_class'); Function wps_first_post_class ($ square) {global $ wp_query; If (0 == $ wp_query- & gt; current_post) $ square [] = 'first'; Return $ class; }    

No comments:

Post a Comment