I'm developing my new theme using Hybrid core framework
and trying to add my class item
on hybrid_post_attributes
generated class using filter with this code.
add_filter( 'hybrid_post_attributes', 'my_post_atributes');
function my_post_atributes($attributes){
return $attributes['class'] = substr_replace($attributes['class'], ' item', -1);
}
I want my 'item' class to be added as the last class from 'hybrid_post_attributes' classes. Here's hybrid_post_attributes
function.
function hybrid_post_attributes() {
$attributes = array();
$output = '';
$attributes['id'] = 'post-' . get_the_ID();
$attributes['class'] = join( ' ', hybrid_get_post_class() );
$attributes = apply_atomic( 'post_attributes', $attributes );
foreach( $attributes as $attr => $value )
$output .= " {$attr}='{$value}'";
echo $output;
}
And here's hybrid_get_post_class function.
function hybrid_get_post_class( $class = '', $post_id = null ) {
static $post_alt;
$post = get_post( $post_id );
/* Make sure we have a real post first. */
if ( !empty( $post ) ) {
$post_id = $post->ID;
/* Add hentry for microformats compliance, the post type, and post status. */
$classes = array( 'hentry', $post->post_type, $post->post_status );
/* Post alt class. */
$classes[] = 'post-' . ++$post_alt;
$classes[] = ( $post_alt % 2 ) ? 'odd' : 'even alt';
/* Author class. */
$classes[] = 'author-' . sanitize_html_class( get_the_author_meta( 'user_nicename' ), get_the_author_meta( 'ID' ) );
/* Sticky class (only on home/blog page). */
if ( is_home() && is_sticky() && !is_paged() )
$classes[] = 'sticky';
/* Password-protected posts. */
if ( post_password_required() )
$classes[] = 'protected';
/* Has excerpt. */
if ( post_type_supports( $post->post_type, 'excerpt' ) && has_excerpt() )
$classes[] = 'has-excerpt';
/* Has <!--more--> link. */
if ( !is_singular() && false !== strpos( $post->post_content, '<!--more-->' ) )
$classes[] = 'has-more-link';
/* Post format. */
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) {
$post_format = get_post_format( $post_id );
$classes[] = ( ( empty( $post_format ) || is_wp_error( $post_format ) ) ? 'format-standard' : "format-{$post_format}" );
}
/* Add category and post tag terms as classes. */
if ( 'post' == $post->post_type ) {
foreach ( array( 'category', 'post_tag' ) as $tax ) {
foreach ( (array)get_the_terms( $post->ID, $tax ) as $term ) {
if ( !empty( $term->slug ) )
$classes[] = $tax . '-' . sanitize_html_class( $term->slug, $term->term_id );
}
}
Did my way of using filter wrong?
Thanks.