add support for featured image, post formats, thumbnails in your theme

16 Aug

add support for featured image, post formats, thumbnails in your theme

To add support for featured image, post format, thumbnail, post-thumbnails,background image, custom header, tiny MCE editor, and translation, add the following codes to functions.php file.

if ( ! function_exists('custom_theme_features') ) {

// Register Theme Features
function custom_theme_features()  {

	// Add theme support for Automatic Feed Links
	add_theme_support( 'automatic-feed-links' );

	// Add theme support for Post Formats
	add_theme_support( 'post-formats', array( 'status', 'quote', 'gallery', 'image', 'video', 'audio', 'link', 'aside', 'chat' ) );

	// Add theme support for Featured Images
	add_theme_support( 'post-thumbnails' );

	 // Set custom thumbnail dimensions
	set_post_thumbnail_size( 0, 0, true );

	// Add theme support for Custom Background
	$background_args = array(
		'default-color'          => '',
		'default-image'          => '',
		'default-repeat'         => '',
		'default-position-x'     => '',
		'wp-head-callback'       => '',
		'admin-head-callback'    => '',
		'admin-preview-callback' => '',
	);
	add_theme_support( 'custom-background', $background_args );

	// Add theme support for Custom Header
	$header_args = array(
		'default-image'          => '',
		'width'                  => 0,
		'height'                 => 0,
		'flex-width'             => false,
		'flex-height'            => false,
		'uploads'                => true,
		'random-default'         => true,
		'header-text'            => true,
		'default-text-color'     => 'Office Plus',
		'wp-head-callback'       => '',
		'admin-head-callback'    => '',
		'admin-preview-callback' => '',
	);
	add_theme_support( 'custom-header', $header_args );

	// Add theme support for HTML5 Semantic Markup
	add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );

	// Add theme support for document Title tag
	add_theme_support( 'title-tag' );

	// Add theme support for custom CSS in the TinyMCE visual editor
	add_editor_style();

	// Add theme support for Translation
	load_theme_textdomain( 'text_domain', get_template_directory() . '/language' );
}
add_action( 'after_setup_theme', 'custom_theme_features' );

It is important to note that, these codes add support for different things. This lines add support for feedback links support.

Add theme support for Automatic Feed Links

The line below adds theme support for Automatic Feed Links.

add_theme_support( 'automatic-feed-links' );

Add theme support for Post Formats

The line below adds theme support for Post Formats like status, quote, gallery, image, video, audio, etc.

add_theme_support( 'post-formats', array( 'status', 'quote', 'gallery', 'image', 'video', 'audio', 'link', 'aside', 'chat' ) );

Add theme support for Custom Background

The line below adds theme support for Add theme support for Custom Background image.

$background_args = array(
		'default-color'          => '',
		'default-image'          => '',
		'default-repeat'         => '',
		'default-position-x'     => '',
		'wp-head-callback'       => '',
		'admin-head-callback'    => '',
		'admin-preview-callback' => '',
	);
	add_theme_support( 'custom-background', $background_args );

And so on. Rest of the codes are self explanatory. If you find anything, ambiguous, please leave comment, or email me. I would be more than happy to respond back to you.

Happy Coding !!!

Bydr.code.skm

I am backend developer with passion in Web Application development using latest technologies like Laravel, PHP7, React, ECMAScript 6 and WordPress. I prefer spending time analyzing big data with Apache Spark. Apart from that, I do photography.