Support Home > Appearance > Content Options

Content Options

Content Options allows site owners to make small visual modifications across their site, like hiding the post date or displaying an excerpt instead of a full post.

Content Options: Customizer

Adding Support

Theme developers can add support for Content Options by following these simple steps.

add_theme_support( 'jetpack-content-options', array(
	'blog-display'       => 'content', // the default setting of the theme: 'content', 'excerpt' or array( 'content', 'excerpt' ) for themes mixing both display.
	'author-bio'         => true, // display or not the author bio: true or false.
	'author-bio-default' => false, // the default setting of the author bio, if it's being displayed or not: true or false (only required if false).
	'masonry'            => '.site-main', // a CSS selector matching the elements that triggers a masonry refresh if the theme is using a masonry layout.
	'post-details'       => array(
		'stylesheet'      => 'themeslug-style', // name of the theme's stylesheet.
		'date'            => '.posted-on', // a CSS selector matching the elements that display the post date.
		'categories'      => '.cat-links', // a CSS selector matching the elements that display the post categories.
		'tags'            => '.tags-links', // a CSS selector matching the elements that display the post tags.
		'author'          => '.byline', // a CSS selector matching the elements that display the post author.
		'comment'         => '.comments-link', // a CSS selector matching the elements that display the comment link.
	),
	'featured-images'    => array(
		'archive'         => true, // enable or not the featured image check for archive pages: true or false.
		'archive-default' => false, // the default setting of the featured image on archive pages, if it's being displayed or not: true or false (only required if false).
		'post'            => true, // enable or not the featured image check for single posts: true or false.
		'post-default'    => false, // the default setting of the featured image on single posts, if it's being displayed or not: true or false (only required if false).
		'page'            => true, // enable or not the featured image check for single pages: true or false.
		'page-default'    => false, // the default setting of the featured image on single pages, if it's being displayed or not: true or false (only required if false).
	),
) );

Blog Display

Lets users choose between displaying the full content of each post or an excerpt on the blog and archives like category, tag, and date archive pages. A “default” option is also available for themes that mix excerpts and full post based on post format.

Author Bio

Lets users hide the author bio on single posts.

author-bio-default is only needed if the theme doesn’t display the Author Bio by default (false).

Use a template tag to output the author bio where you would like to show it. Be sure to include the function_exists() check to avoid fatal errors if Jetpack isn’t activated.

<?php if ( function_exists( 'jetpack_author_bio' ) ) jetpack_author_bio(); ?>

The avatar size can be filtered:

/**
 * Author Bio Avatar Size.
 */
function themeslug_author_bio_avatar_size() {
	return 120; // in px
}
add_filter( 'jetpack_author_bio_avatar_size', 'themeslug_author_bio_avatar_size' );

Masonry

If the theme is using a Masonry layout, the masonry argument will be required to allow the Customizer preview to regenerate the layout.

Post Details

Lets users show or hide the post date, tags, categories, or author.

It assumes that date, tags, categories, and author are displayed by default.

Featured Image

Lets users display featured images on blog and archive pages, single posts, and pages.

If you are displaying the Featured Image outside of the loop, the theme will require a custom function. Be sure to include the function_exists() check to avoid fatal errors if Jetpack isn’t activated. e.g.:

/**
 * Show/Hide Featured Image outside of the loop.
 */
function themeslug_jetpack_featured_image_display() {
	if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
		return true;
	} else {
		$options         = get_theme_support( 'jetpack-content-options' );
		$featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;

		$settings = array(
			'post-default' => ( isset( $featured_images['post-default'] ) && false === $featured_images['post-default'] ) ? '' : 1,
			'page-default' => ( isset( $featured_images['page-default'] ) && false === $featured_images['page-default'] ) ? '' : 1,
		);

		$settings = array_merge( $settings, array(
			'post-option'  => get_option( 'jetpack_content_featured_images_post', $settings['post-default'] ),
			'page-option'  => get_option( 'jetpack_content_featured_images_page', $settings['page-default'] ),
		) );

		if ( ( ! $settings['post-option'] && is_single() )
			|| ( ! $settings['page-option'] && is_singular() && is_page() ) ) {
			return false;
		} else {
			return true;
		}
	}
}

and then it will need to be added to your featured image check, e.g.:

if ( is_single() && has_post_thumbnail() && themeslug_jetpack_featured_image_display() ) {
	wp_enqueue_script( 'themeslug-single-thumbnail', get_template_directory_uri() . '/js/single-thumbnail.js', array( 'jquery' ), '20161125', true );
}

archive-default, post-default, page-default are only needed if by default the theme doesn’t display the Featured Image (false). A custom fallback function will be required to display the Featured Image if needed, e.g.:

/**
 * Display a Featured Image on archive pages if option is ticked.
 */
function themeslug_jetpack_featured_image_archive_display() {
	if ( ! function_exists( 'jetpack_featured_images_remove_post_thumbnail' ) ) {
		return false;
	} else {
		$options         = get_theme_support( 'jetpack-content-options' );
		$featured_images = ( ! empty( $options[0]['featured-images'] ) ) ? $options[0]['featured-images'] : null;

		$settings = array(
			'archive-default' => ( isset( $featured_images['archive-default'] ) && false === $featured_images['archive-default'] ) ? '' : 1,
		);

		$settings = array_merge( $settings, array(
			'archive-option'  => get_option( 'jetpack_content_featured_images_archive', $settings['archive-default'] ),
		) );

		if ( $settings['archive-option'] ) {
			return true;
		} else {
			return false;
		}
	}
}

Now it needs to be added to the page where the featured image will be displayed, e.g.:

if ( themeslug_jetpack_featured_image_archive_display() && has_post_thumbnail() ) {
	the_post_thumbnail();
}
  • Categories

  • Contact Us

    Need more help? Feel free to contact us.