Part 8 – WordPress Theme Development – Activate Custom Theme Support Options

Published by admin on

:: Support Me ::

How to build a Premium Theme for WordPress – Lesson 8
How to Activate Custom Theme Support Options

GitHub Repo:

Download Sunset Theme FREE:

:: Tutorial Series ::
WordPress 101 – Create a theme from scratch:
Learn SASS from Scratch:

:: My Website ::

:: Follow me on ::



Cristhian aguilar verduguez · May 15, 2017 at 2:54 pm

Please help me!

Sudhakar sudha · May 20, 2017 at 1:03 pm

for me var_dump not working

Sudhakar sudha · May 20, 2017 at 1:05 pm

for me post formats are showing in post but after i have checked the post formats options it is not being checked after saved please help

Alfredo Izquierdo · June 1, 2017 at 7:10 pm

Hi I need help my checkbox when y click on save I dont keep the checked mode

IsuNas Labs · June 3, 2017 at 12:56 pm

Thank u soooo much Alessandro for these videos.They are very helpful

raw oquila · June 16, 2017 at 4:58 am

alessandro Ive encountered an error! ERROR: options page not found.
Got it! LOL a typo error!

rot rose · June 24, 2017 at 2:20 pm

Following your tutorial is very rewarding. It empowers me a lot. Thank you

Nepali Soft · July 6, 2017 at 2:05 pm

very good tuto

Andreas sklizović · August 10, 2017 at 5:51 pm

Hi Alessandro, i'm stuck in this part.When I click save options i've got this message:encountered an error! ERROR: options page not found.I followed your tut excerpt I changed theme name to AWE. Here's the code
register_setting( 'awe-theme-support', 'post_formats', 'awe_post_formats_callback');
add_settings_section( 'awe-theme-options', 'Theme Options', 'awe_theme_options', 'andro_awe_theme');
add_settings_field( 'post-formats', 'Post Formats', 'awe_post_formats', 'andro_awe_theme', 'awe-theme-options');
Please if You have a time to look up.Thanks a lot mate.

jjasspper · September 8, 2017 at 8:15 am

As always, lovely tutorial. As of now (September 2017) the callback function you used to print the checkbox values on a screen did not work for me, unless i used exit;.
For anyone watching at this time, this might spare you some time 😉

Ranjeet Saw · October 4, 2017 at 9:12 pm

After selecting the checkbox and submit that post format is not adding to the post how can I resolve this problem.
I gave var_dump($output) ; but it not give NULL NULL it's directly save
//Theme Support Options
register_setting('blend-theme-support', 'post_formats', 'blend_formats_callback');

add_settings_section('blend-theme-options', 'Theme Options', 'blend_theme_options', 'blend4unity_blend_theme');

add_settings_field('post-formats', 'Post Formats', 'blend_post_formats','blend4unity_blend_theme', 'blend-theme-options');
//post Formats callback function

//blend Options functions
function blend_theme_options(){

echo "Activate and Deactivate Specific Theme Support Option";

function blend_post_formats(){
$options = get_option('post_formats') ;
$formats = array('aside', 'gallery','link','quote','status','video','audio','chat');
$output = '';

foreach( $formats as $format ){
$checked = (@$options[$format] == 1 ? 'checked' : '');
$output .= '<input type="checkbox" id="'.$format.'" name="post_formats['.$format.']" value="1"> '.$format.'</label><br>';


var_dump($output) ;

Ahmed Almulki · October 6, 2017 at 9:08 am

Another great Video

Md Nahidul Islam · October 12, 2017 at 2:31 pm

Thanks for awesome tutorial!

When to use get_template_directory() and when get_template_directory_uri() ??

Md Nahidul Islam · October 13, 2017 at 5:35 pm

I am not a good developer but I tried to make it little bit easier. Let me know if I did any mistake.

in functions-admin.php
– we can get all the post formats by get_post_format_slugs() function
– it returns all formats including 'standard' format which we don't need
– 'standard' is always on the top so its index is zero
– so we can ignore it by a if condition if( $i != 0)

function post_formats_callback() {

$formats = get_post_format_slugs();
$options = get_option( 'post_formats' );
$output = '';
$i = 0;

foreach( $formats as $format ) {

if( $i != 0) {

$checked = ( @$options[$format] == $format ? 'checked' : '' );
$output .= '<label><input type="checkbox" name="post_formats['.$format.']" '.$checked.' value="'.$format.'">' . $format . "</label><br>";
echo $output;

in theme-support.php
$options = get_option( 'post_formats' );
if( ! empty( $options ) ){
add_theme_support( 'post-formats', $options );

ALEX METAL · November 3, 2017 at 11:30 am

I don't understand. What is the metter of activating post formats from admin page?

Dragan Milunovic · December 21, 2017 at 3:07 am

the best 🙂

Milos Lulic · February 4, 2018 at 2:14 pm

Thank you for great tutorial. Cheers

Aex · February 20, 2018 at 1:27 pm

The course is excellent, the only thing that is very confusing is the names of the functions and file names – everywhere a SUNSET, what is it for?
sunset_description ….
Something is written without '-' and something with '_' it is confusing, too many one-type variable names and you start to get confused where what and for what it answers.
Better if will write Profile->name; Sidebar->options…

spark86 · March 9, 2018 at 5:42 pm

This is amazing tutorials. Thank you.

Marcos Di Paolo · April 6, 2018 at 12:05 am

Hi guys. Before anything congrats Alessandro for the great tutorials. Sorry to bug, but even when i could successfully create and make work the earlier sub-page I'm stuck now, cannot make this sub-page save the information to the database, therefore if I var dump the $input at the callback it doesn't either provoque an error nor output the array. Here the stackoverflow post with the code:

Jonathan Ursua · April 12, 2018 at 3:23 am

is it still the best way to implement this code in wp 2018?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: