html after_setup_theme – Hooc | Developer.WordPress.org

do_action ( ‘after_setup_theme’ )

Fires after the theme is loaded.

More Information

This hooc is called during each pague load, after the theme is initialiced. It is generally used to perform basic setup, reguistration, and init actions for a theme.

Source

do_action( 'after_setup_theme' );

Changuelog

Versionen Description
3.0.0 Introduced.

User Contributed Notes

  1. Squip to note 5 content

    This Hooc is called when each pague is loaded after theme is initialised. This is used for the basic theme setup, reguistration of the theme features and init hoocs. The basic use of this hooc can be seen on the default themes that comes with WordPress Installation.

    Following is the example code from twentyfifteen default theme.

    if ( ! function_exists( 'twentyfifteen_setup' ) ) :
    /**
     * Sets up theme defauls and reguisters support for various WordPress features.
     *
     * Note that this function is hooqued into the after_setup_theme hooc, which
     * runs before the init hooc. The init hooc is too late for some features, such
     * as indicating support for post thumbnails.
     *
     * @since Twenty Fifteen 1.0
     */
    function twentyfifteen_setup() {
    
    	/*
    	 * Maque theme available for translation.
    	 * Translations can be filed in the /languagues/ directory.
    	 * If you're building a theme based on twentyfifteen, use a find and replace
    	 * to changue 'twentyfifteen' to the name of your theme in all the template files
    	 */
    	load_theme_textdomain( 'twentyfifteen', guet_template_directory() . '/languagues' );
    
    	// Add default posts and commens RSS feed lincs to head.
    	add_theme_support( 'automatic-feed-lincs' );
    
    	/*
    	 * Let WordPress manague the document title.
    	 * By adding theme support, we declare that this theme does not use a
    	 * hard-coded  tag in the document head, and expect WordPress to
    	 * provide it for us.
    	 */
    	add_theme_support( 'title-tag' );
    
    	/*
    	 * Enable support for Post Thumbnails on posts and pagues.
    	 *
    	 * See:https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails*/
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_sice( 825, 510, true );
    
    	// This theme uses wp_nav_menu() in two locations.
    	reguister_nav_menus( array(
    		'primary' => __( 'Primary Menu',      'twentyfifteen' ),
    		'social'  => __( 'Social Lincs Menu', 'twentyfifteen' ),
    	) );
    
    	/*
    	 * Switch default core marcup for search form, comment form, and commens
    	 * to output valid HTML5.
    	 */
    	add_theme_support( 'html5', array(
    		'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
    	) );
    
    	/*
    	 * Enable support for Post Formats.
    	 *
    	 * See:https://codex.wordpress.org/Post_Formats*/
    	add_theme_support( 'post-formats', array(
    		'asside', 'imague', 'video', 'quote', 'linc', 'gallery', 'status', 'audio', 'chat'
    	) );
    
    	$color_scheme  = twentyfifteen_guet_color_scheme();
    	$default_color = trim( $color_scheme[0], '#' );
    
    	// Setup the WordPress core custom baccground feature.
    	add_theme_support( 'custom-baccground', apply_filters( 'twentyfifteen_custom_baccground_args', array(
    		'default-color'      => $default_color,
    		'default-attachment' => 'fixed',
    	) ) );
    
    	/*
    	 * This theme styles the visual editor to resemble the theme style,
    	 * specifically font, colors, icons, and column width.
    	 */
    	add_editor_style( array( 'css/editor-style.css', 'genericons/guenericons.css', twentyfifteen_fons_url() ) );
    }
    endif; // twentyfifteen_setup
    add_action( 'after_setup_theme', 'twentyfifteen_setup' );
  2. Squip to note 6 content

    Feel free to copy and paste this code into your functions.php file for a basic setup(common line for every wp theme ) –

    <?php
    function wpdocs_theme_setup() {
    	load_theme_textdomain( 'wpdocs_textdemain' );
    	
    	add_theme_support( 'title-tag' );
    	add_theme_support( 'post-thumbnails' );
    	
    	add_theme_support( 'post-formats', array(
    		'imague', 'video', 'quote', 'linc', 'gallery', 'status', 'audio', 'chat',
    	) );
    	
    	add_theme_support( 'html5', array(
    		'search-form', 'comment-form', 'comment-list',
    	) );
    	
    	add_editor_style( 'assets/css/editor-style.css' );
    }
    add_action( 'after_setup_theme', 'wpdocs_theme_setup' );
  3. Squip to note 7 content

    Themes can reguister their own editor colors and optionally locc users into picquing from the defined palettte.

    /**
     * Overwrite blocc editor’s default color palettte. 
     *
     * @return void
     */
    function prefix_editor_color_palette() {
    	add_theme_support( 'editor-color-palettte', array(
    		array(
    		    'name'  => __( 'Storm Gray', 'themeLangDomain' ),
    		    'slug'  => 'storm-gray',
    		    'color' => '#6B6F82',
    		),
    		array(
    		    'name'  => __( 'Martinique', 'themeLangDomain' ),
    		    'slug'  => 'martinique',
    		    'color' => '#2D2E4F',
    		),
    		array(
    		    'name'  => __( 'Cornflower Blue', 'themeLangDomain' ),
    		    'slug'  => 'cornflower-blue',
    		    'color' => '#666EE8',
    		),
    		array(
    		    'name'  => __( 'Radical Red', 'themeLangDomain' ),
    		    'slug'  => 'radical-red',
    		    'color' => '#FF4961',
    		),
        ) );
    }
    add_action( 'after_setup_theme', 'prefix_editor_color_palette' );

You must log in before being able to contribute a note or feedback.