I’m assuming that the class divide is going to be the same in the css instead of divide-sidebar.
How about:
<ul>
<?php while ( have_posts() ) : the_post(); ?>
<div class="divide">
/*body of my post*/
<li></li>
</div>
<?php endwhile; ?>
</ul>
css:
.divide li{
background-image: url(images/someimage.png);
width: 100%;
background-repeat: repeat-x;
margin: 27px 0 0;
}
.divide li:last-child{
display: none;
}
Hi man,
Actually i also thought about some tricks, using list and last-child for it.
But i don’t sure that your example is correct.
Is it normal to put whole cycle into list?
Is it normal to put whole content into divide div?
I think the result of your code will be divide div in the top of each post and that’s all.
The css is targeting li not just the div so it should show at the bottom of the post but you should try it and then let us know what issues you may have or better yet, a link to an example of it.
using php; example:
<?php if( $wp_query->current_post != $wp_query->post_count-1 ) echo '<div class="divide"></div>'; ?>
Thanks a lot, alchymyth. That is good and correct solution.
But have one more question about such situation in sidebar (widget) zone.
I use such sidebar.php:
<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>
<div id="sidebar" class="site-sidebar">
<?php dynamic_sidebar( 'sidebar1' ); ?>
</div>
<?php endif; ?>
And such in functions.php:
<?php
function mysite_widgets_init() {
register_sidebar(array(
'name' => __( 'Main sidebar' ),
'id' => 'sidebar1',
'before_widget' => '<div id="posts" class="posts">',
'after_widget' => '</ul></div><div class="divide-sidebar"></div></div>',
'before_title' => '<div class="sidebar-title"><p>',
'after_title' => '</p></div><div class="links"><ul class="links">',
) );
}?>
So first question, how not to show <div class=”divide-sidebar”> after last widget (how define current widget in wordpress)?
And the second one, is it normal to use such code in fuctions.php or i need trying to avoid putting a lot of html code into parameters of mysite_widgets_init function?
there was a recent article about how to add specific classes to the first and last widget in a sidebar;
http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets?replies=9
or as plugin http://wordpress.org/plugins/widget-css-classes/
what theme are you working with?
please contact the developer of your theme with any further theme specific questions.
commercial themes are not supported in this forum; http://codex.wordpress.org/Forum_Welcome#Commercial_Products
Actually, i can just send you another example, if it is make sence for u. I just work with wordpress and try to do my best to make all things i need there. (i mean i am developer of theme, so it is not commercial)
How can I set like this, If a previous post/newer post link is not available then css class will not show up. Look this http://awesomescreenshot.com/0c339j4ff9