Display Featured Posts Grid on Static Page (Gazette)

Question

I’m using the Gazette theme which has a jet pack enabled featured posts grid when the front page is set to show latest posts.

I would like to use a static page instead of recent posts, but keep the featured posts grid.


UPDATE

I was able to figure this out with a little moral support from the community

Link to answer – Display Featured Posts Grid on Static Page (Gazette)


Demo: https://gazettedemo.wordpress.com/

Source: https://public-api.wordpress.com/rest/v1/themes/download/gazette.zip

Code parts associated with the featured posts

@ index.php

<?php
    if ( is_home() ) {
        // Include the featured content template.
        get_template_part( 'featured-content' );
    }
?>

    <?php if ( have_posts() ) : ?>

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

            <?php
                get_template_part( 'content', get_post_format() );
            ?>

        <?php endwhile; ?>

        <?php the_posts_navigation(); ?>

    <?php else : ?>

        <?php get_template_part( 'content', 'none' ); ?>

    <?php endif; ?>

@ functions.php line 197

wp_enqueue_script( 'gazette-featured-content', 
get_template_directory_uri() . '/js/featured-content.js', 
array( 'jquery' ), '20150507', true );

@ featured-content.php

$featured_posts = gazette_get_featured_posts();
if ( empty( $featured_posts ) ) {
    return;
}
?>
    <?php
        foreach ( $featured_posts as $post ) {
            setup_postdata( $post );

             // Include the featured content template.
            get_template_part( 'content', 'featured-post' );
        }

        wp_reset_postdata();
    ?>

@ content-featured-post.php

/**
 * The template for displaying featured posts on the front page
 */
<?php
    // Output the featured image.
    if ( has_post_thumbnail() ) {
        the_post_thumbnail( 'gazette-featured-content-thumbnail' );
    }
?>

@ inc/jetpack.php line 22

add_theme_support( 'featured-content', array(
    'filter'      => 'gazette_get_featured_posts',
    'description' => __( 'Omitted', 'gazette' ),
    'max_posts'   => 6,
) );

@ js/featured-content.js line 24

var featuredContent, header, primary;
featuredContent = $( '#featured-content' );
header = $( '#masthead' );
primary = $( '#primary' );

if ( ! featuredContent.length ) {
    return;
}

@ js/header.js line 24

function headerStyle() {
    var featuredContent, featuredContentHeight;

    featuredContent = $( '#featured-content' );
    featuredContentHeight = 0;
    if ( featuredContent.length ) {
        featuredContentHeight = featuredContent.outerHeight();
    }

    if ( $( '.site-branding' ).outerWidth() === 0 ) {
        $( 'body' ).addClass( 'no-branding' );
    } else {
        $( 'body' ).removeClass( 'no-branding' );
    }

These are all the references I found to the featured posts grid layout.

How can I modify to display the grid on the homepage setup as a static page?

Notes

I added this to the page.php and it does show up in the source for static, but simply does not display.

if ( is_page(35) ) {
    // Include the featured content template.
    get_template_part( 'featured-content' );
}
0
, , Jarmerson 5 years 2016-08-19T09:01:17-05:00 0 Answers 72 views 0

Leave an answer

Browse
Browse