Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Support request] More full width posts

Home Forums Support More full width posts

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #405727
    Mark

    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?

    GP Premium 1.4.3
    #406045
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #406109
    Mark

    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! 🙂

    #406362
    Tom
    Lead Developer
    Lead Developer

    Hmm, hard to tell without seeing the site. Can you try the adjusted code above?

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.