Archived topic
More full width posts
3 replies · Started by Mark on October 18, 2017
Hello,
GP Premium has amazing feature with displaying first post full and the rest as excerpts in masonry. But what if I would want to have (lets say) first three posts full width, and the rest as excerpts?
Hi there,
Try this PHP:
add_filter( 'post_class', 'tu_full_width_posts' );
function tu_full_width_posts( $classes ) {
global $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( 1 == $paged && ( 0 == $wp_query->current_post || 1 == $wp_query->current_post || 2 == $wp_query->current_post ) ) {
$classes[] = 'full-width-post';
}
return $classes;
}
Then this CSS:
article.full-width-post.masonry-post {
width: 100% !important;
}
Let me know if that helps or not :)
Hello Tom!
Well, partially. It successfully inserts class 'full-width-post' into first three posts, but for some reason, it only shows full width posts only under <1000px display. Over 1000px, it shows first post full and rest as masonry.
But the main problem is, that when you click 'More posts' aka page 2, it displays another these 3 posts full-width again. And I don't want it to.
EDIT: I resolved it with this code and it works.
<?php add_filter( 'post_class', 'tu_full_width_posts' );
function tu_full_width_posts( $classes ) {
global $wp_query;
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) :1;
if ( $wp_query->current_post < 3 && 1 == $paged ) {
$classes[] = 'width6';
}
return $classes;
}
?>
Btw your theme and support is absolutely great! :)
Hmm, hard to tell without seeing the site. Can you try the adjusted code above?