jetpack featured content

20
Showcase your content using Jetpack's Featured Content by Mikey Arce 1

Upload: mikeyarce

Post on 14-Aug-2015

202 views

Category:

Technology


0 download

TRANSCRIPT

Showcase your content using

Jetpack's Featured Content

by Mikey Arce 1

Featured Content provides a way for a user or client to visually change the display of posts easily, using tags.

• Doesn't duplicate content

• No need to install another plugin

• Makes it really easy for users

by Mikey Arce 2

Featured Content

Jetpack's Featured Content adds a Customizer Section to allow you to configure the settings.

by Mikey Arce 3

Setting it up

1. Add a tag of your choice to the Customizer (e.g. "Featured", "New", "News", etc)

2. Tag your posts with that tag!

3. Profit.

by Mikey Arce 4

Examples

by Mikey Arce 5

by Mikey Arce 6

by Mikey Arce 7

by Mikey Arce 8

by Mikey Arce 9

How do you use it?

by Mikey Arce 10

Add Theme Supportadd_theme_support( 'featured-content', array( 'filter' => 'mytheme_get_featured_posts', 'max_posts' => 20, 'post_types' => array( 'post', 'page' ),) );

by Mikey Arce 11

Return the posts into a functionfunction mytheme_get_featured_posts() { return apply_filters( 'mytheme_get_featured_posts', array() );}

by Mikey Arce 12

Make sure they existfunction mytheme_has_featured_posts( $minimum = 1 ) { if ( is_paged() ) return false;

$minimum = absint( $minimum ); $featured_posts = apply_filters( 'mytheme_get_featured_posts', array() );

if ( ! is_array( $featured_posts ) ) return false;

if ( $minimum > count( $featured_posts ) ) return false;

return true;}

by Mikey Arce 13

Let's add them into our themeWe're going to use get_template_part to be smart.if ( is_front_page() && mytheme_get_featured_posts() ) { // Include the featured content template. get_template_part( 'content', 'featured' );}

by Mikey Arce 14

get_template_part

by Mikey Arce 15

Now let's display themcontent-featured.php

<?php if( is_front_page() && mytheme_get_featured_posts() ) : $featured_posts = mytheme_get_featured_posts(); $post_count = count($featured_posts); ?>

by Mikey Arce 16

<div class="featured-posts"> <?php foreach( $featured_posts as $post ) : setup_postdata( $post ); ?> <figure class="cap-left"> <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> <figcaption> <?php the_title(); ?> </figcaption> </a> </figure> <?php endforeach; ?></div> <!-- .featured-posts !--><?php endif; ?>

by Mikey Arce 17

Outputting content into a slider using

Flexslider

by Mikey Arce 18

Q & EH?

by Mikey Arce 19

mikeyarce.com/featured-content

by Mikey Arce 20