I want to style every other Wordpress post differently one post will have a certain background image and the other post will have a different background image. I'll give the first one that sends me the code that actually works $5. See the attached image to get an idea of what I'm trying to do. Thanks
You just have to use http://wordpress.org/extend/plugins/custom-post-background/ I Guess i get the 5$
I don't want something the end user will have to manage. I want to hard code it into the theme. I searched for several hours trying to figure it out. It seems to have something to do with querying posts. I'll give you rep for giving me a fast answer. Yes, for example post 1,3,5,7, and 9 will have the same background and post 2,4,6,8, and 10 will have the same background. The background image just alternates.
Well Offcourse you are using div for the template so you can try this if ($alt) { $alt = "classnameodd"; } else { $alt = "classnameeven"; } and then to the posts <div class="<?php echo $alt; ?>"> should be in the loop try it
Where exactly do I put that code? I'm guessing that code goes here?????: <?php query_posts('if ($alt) { $alt = "classnameodd"; } else { $alt = "classnameeven"; } '); ?> I got to go to sleep. It's 2 AM here and I have to get up in about 4 hours, but I'll get back with you tomorrow Bohra with some cash if it works.
This should do the trick Paste it on index for example Keep your money! <?php if (have_posts()) : ?> <?php $i = 0; ?> <?php while (have_posts()) : the_post(); ?> <?php $i++; ?> <!-- Post --> <?php if($i%1==0) { ?> <!-- style background 1--> <div class="post" id="post-<?php the_ID(); ?>"> <div class="post-title"> <div class="post-date"> <span><?php the_time('d') ?></span> <?php the_time('M') ?> </div> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> Posted by: <?php the_author() ?> / Category: <?php the_category(', ') ?> </div> <div class="post-entry"> <?php the_content('Read more...'); ?> </div> <div class="post-info"> <?php comments_popup_link('Comments (0)', 'Comment (1)', 'Comments (%)'); ?> / <a href="<?php the_permalink() ?>#respond">Add Comment</a> </div> </div> <div class="clear"></div> <?php }else{ ?> <!-- style background 2 here--> <div class="post" id="post-<?php the_ID(); ?>"> <div class="post-title"> <div class="post-date"> <span><?php the_time('d') ?></span> <?php the_time('M') ?> </div> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> Posted by: <?php the_author() ?> / Category: <?php the_category(', ') ?> </div> <div class="post-entry"> <?php the_content('Read more...'); ?> </div> <div class="post-info"> <?php comments_popup_link('Comments (0)', 'Comment (1)', 'Comments (%)'); ?> / <a href="<?php the_permalink() ?>#respond">Add Comment</a> </div> </div> <div class="clear"></div> <?php } ?> <!-- /Post --> PHP:
None of these seem to be working for me. Here's the wp loop that I have going. I'm just displaying the post, no permalinks etc.: <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="speechbubble"> <div id="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?> PHP:
This is my best attempt at this. I have not tested it, so I have no idea if it will work or not. All you would need to do is go into the css file and change the speechbubble part to have the first background image, then copy it into a speechbubble2 part right underneath and tell it to have the second background image. I apologise if this doesn't help at all. <?php if (have_posts()) : ?> <?php $i = "1"; ?> <?php while (have_posts()) : the_post(); ?> <?php if (i == "1") : ?> <div id="speechbubble"> <?php $i ="2"; ?> <?php elseif (i=="2"): ?> <div id="speechbubble2"> <?php $i = "1"; ?> <?php endif ?> <div id="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?> Code (markup):