WordPress post arrangement using post_class

It just take a little bit more complicated logic: function alternating_post_class($classes) { static $counter = 1; switch ($counter) { case 1: $classes[] = ‘full-width’; break; case 2: case 3; $classes[] = ‘half-width’; break; } $counter = ($counter == 3) ? 1 : $counter + 1; return $classes; } add_filter(‘post_class’, ‘alternating_post_class’);

List of Body Classes Generated by body_class()

Several classes have been added since WordPress 2.8 (when the WPEngineer post was written). I would refer directly to the body_class() Codex entry, which currently lists the following: rtl home blog archive date search paged attachment error404 single postid-(id) page-id-(page_id) attachmentid-(id) attachment-(mime-type) author author-(user_nicename) category category-(slug) tag tag-(slug) page-parent page-child parent-pageid-(id) page-template page-template-(template file name) … Read more

Adding class to featured image

You can add custom class to post thumbnails. the_post_thumbnail accepts array of attribute $attr where you can specify image class. So your code will be. <div class=”home-featured-img”> <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail( ‘full’, array( ‘class’ => ‘responsive-class’ ) ); // show … Read more

How to use post_class function?

Use the post_class filter to test multiple conditions: function wpa_post_class( $classes ) { global $post; if( ! has_post_thumbnail() ) $classes[] = “no-image”; if( get_the_content() == “” ) $classes[] = “no-content”; return $classes; } add_filter( ‘post_class’, ‘wpa_post_class’ ); Then your html will just be: <li id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>

Indirect modification of overloaded property WP_Post::$classes has no effect

If “line 45” is the one that starts with $element->classes[] in your display_element method then try something like this: public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { $element->has_children = ! empty( $children_elements[ $element->ID ] ); if ( ! isset( $element->classes ) ) { $element->classes = array(); } $element->classes[] = ( … Read more

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