Different Length Excerpts for posts with different classes
-
Hello,
I recently had some help form Alchymyth to add classes to my posts on my blog page and he suggested using:
<article id="post-<?php the_ID(); ?>" <?php $extra = ( ( $wp_query->current_post % 5 == 0 && !is_paged() ) ? 'full' : 'half' ) . ( ( ( $wp_query->current_post % 5 == 1 || $wp_query->current_post % 5 == 3 ) && !is_paged() ) ? ' left' : '' ); post_class($extra); ?>>
This works great and in short adds the classes ‘full’ ‘half’ and ‘half left’.
I also use the following to change the length of the excerpts of these posts:
function twentytwelvechild_custom_excerpt_length( $length ) { return 30; } add_filter( 'excerpt_length', 'twentytwelvechild_custom_excerpt_length', 30 ); function twentytwelvechild_new_excerpt_more($more) { global $post; return '... <a href="'. get_permalink($post->ID) . '"><div class="read-more-div">[READ MORE →]</div></a>'; } add_filter('excerpt_more', 'twentytwelvechild_new_excerpt_more');
This sets all posts to have an excerpt length of 30. My question is how can I have a different excerpt length for the posts with the ‘full’ class?
Thank you
James
- The topic ‘Different Length Excerpts for posts with different classes’ is closed to new replies.