Every second post different class in blog view

Give this a try? function oddeven_post_class ( $classes ) { global $current_class; $classes[] = $current_class; $current_class = ($current_class == ‘odd’) ? ‘even’ : ‘odd’; return $classes; } add_filter ( ‘post_class’ , ‘oddeven_post_class’ ); global $current_class; $current_class=”odd”; and be sure you’re using <?php post_class(); ?>

How can i show post_class() within output loop?

You should use get_post_class() From Codex: get_post_class() is not simply a non-echoing alternative to post_class(). get_post_class() does not return a string, but an array that must be processed to produce text similar to what is echoed by post_class(). So $classes = get_post_class(); $output=”<div id=”” . get_the_ID() . ‘” class=”‘ . implode(” “, $classes) . ‘”></div>’;

Add $values to post_class()

Multiple post classes should be separated by a single space or should be in an array. post_class(“$even_odd $current_post $current_in_total”); Or post_class(array($even_odd, $current_post, $current_in_total));

How to change “post_class()” for a custom post type?

As documented here: https://codex.wordpress.org/Function_Reference/post_class#Add_Classes_By_Filters You can add a hook to the ‘post_class’ filter to add/remove classes in the array passed. You can use the various template tags like has_post_format() and others to see what classes you need to add; you’ll have access to the ID of the post in question. You could erase the array … Read more

post_class output in wrong area?

post_class() echos so that’s you’re problem. From the codex: If you would prefer to have the post classes returned instead of echoed, you would want to use get_post_class(). So just do this: $the_post_classes = get_post_class( ‘clearfix’ ); $the_post_class_string = ”; foreach( $the_post_classes as $post_class ) { $the_post_class_string .= $post_class . ‘ ‘; } $defaults = … Read more

How to assign classes to all elements?

Jquery solution: **assuming your posts are in a division with the class of “post”. <script type=”text/javascript”> $(document).ready(function(){ $(“.post p”).each(function(){ $(this).addClass(‘paragraph’); }); $(“.post ul”).each(function(){ $(this).addClass(‘list’); }); //add more lines here to select more elements }); </script> Paste this in your footer. *you need jquery installed. And better yet would be to enque this using http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)