Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

after_setup_theme

Fires after the active theme's functions.php has loaded. Use it to add theme support, image sizes and menu locations.

  • Type Action
  • From WordPress
  • Since 3.0.0
  • Fired in wp-settings.php

When it fires

after_setup_theme runs on every request, straight after WordPress loads the active theme (and its parent theme) and before init. Plugins have loaded too, so it's the first hook where both plugins and the theme are in place.

The current user hasn't been set up yet and nothing has been queried, so don't check capabilities or use conditional tags here.

Parameters

None. Your callback takes no arguments.

Example: Add featured images, an image size and a menu location

PHP
add_action( 'after_setup_theme', function () {
	add_theme_support( 'post-thumbnails' );
	add_image_size( 'card', 600, 400, true );
	register_nav_menus(
		array(
			'footer-links' => __( 'Footer links', 'my-snippets' ),
		)
	);
} );

Good to know

  • New image sizes only apply to images uploaded from now on. Regenerate thumbnails to create them for older images.
  • At the same priority the theme's callbacks run after yours, so use a priority above 10 if you need to override the theme's add_theme_support() settings.
  • Block themes already support featured images and use the Navigation block rather than menu locations.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.