JetPack Featured Content
-
Hi guys
I’m using Jetpack’s Featured Content feature, and I cannot seem to get it to work.
It is being used in a Parent-Child theme, and neither theme (Parent nor Child) is showing the post tagged “featured”; it seems to be showing the first ever post in the category (if not the first one ever) and that post is in the Trash!
The funny thing is, it was working with the old theme, which has been replaced since it is not responsive.
Jetpack Support couldn’t help and told me to check out here.
Within theme setup
add_theme_support( 'featured-content', array( 'filter' => 'classic_get_featured_posts', 'max_posts' => 1, 'post_types' => array( 'post', 'page' ), ) );
EOF functions.php
function classic_get_featured_content( $num = 1 ) { global $featured; $featured = apply_filters( 'classic_featured_content', array() ); if ( is_array( $featured ) || $num >= count( $featured ) ) return true; return false; }
HTML on archive page
<div class="featured"> <?php if (classic_get_featured_content()) { $featured_posts = classic_get_featured_content(); foreach ( (array) $featured_posts as $order => $post ) : setup_postdata( $post ); get_template_part( 'content', 'featured-post' ); endforeach; wp_reset_postdata(); } ?> </div>
content-featured-post.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="featured-thumbnail"> <?php the_post_thumbnail(); ?> </div> <div class="featured-title"> <?php the_title('<h1 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h1>'); ?> </div> <div class="featured-excerpt"> <?php the_excerpt(); ?> </div> <div class="featured-more"> <?php echo '<div class="post-link">'; ?> <a class="more-link" href="<?php the_permalink(); ?>"><?php _e('Continue reading'); ?></a> <?php echo '</div>'; ?> </div> </article><!-- #post-## -->
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘JetPack Featured Content’ is closed to new replies.