twentyfifteen_setup

Sets up theme defaults and registers support for various WordPress features.

Description

twentyfifteen_setup(); 

Note that this function is hooked into the after_setup_theme hook, which runs before the init hook. The init hook is too late for some features, such as indicating support for post thumbnails.


Usage

  1. if ( !function_exists( 'twentyfifteen_setup' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyfifteen_setup(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function twentyfifteen_setup() { 
  2.  
  3. /** 
  4. * Make theme available for translation. 
  5. * Translations can be filed in the /languages/ directory. 
  6. * If you're building a theme based on twentyfifteen, use a find and replace 
  7. * to change 'twentyfifteen' to the name of your theme in all the template files 
  8. */ 
  9. load_theme_textdomain( 'twentyfifteen', get_template_directory() . '/languages' ); 
  10.  
  11. // Add default posts and comments RSS feed links to head. 
  12. add_theme_support( 'automatic-feed-links' ); 
  13.  
  14. /** 
  15. * Let WordPress manage the document title. 
  16. * By adding theme support, we declare that this theme does not use a 
  17. * hard-coded <title> tag in the document head, and expect WordPress to 
  18. * provide it for us. 
  19. */ 
  20. add_theme_support( 'title-tag' ); 
  21.  
  22. /** 
  23. * Enable support for Post Thumbnails on posts and pages. 
  24. * See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails 
  25. */ 
  26. add_theme_support( 'post-thumbnails' ); 
  27. set_post_thumbnail_size( 825, 510, true ); 
  28.  
  29. // This theme uses wp_nav_menu() in two locations. 
  30. register_nav_menus( array( 
  31. 'primary' => __( 'Primary Menu', 'twentyfifteen' ),  
  32. 'social' => __( 'Social Links Menu', 'twentyfifteen' ),  
  33. ) ); 
  34.  
  35. /** 
  36. * Switch default core markup for search form, comment form, and comments 
  37. * to output valid HTML5. 
  38. */ 
  39. add_theme_support( 'html5', array( 
  40. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' 
  41. ) ); 
  42.  
  43. /** 
  44. * Enable support for Post Formats. 
  45. * See: https://codex.wordpress.org/Post_Formats 
  46. */ 
  47. add_theme_support( 'post-formats', array( 
  48. 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat' 
  49. ) ); 
  50.  
  51. $color_scheme = twentyfifteen_get_color_scheme(); 
  52. $default_color = trim( $color_scheme[0], '#' ); 
  53.  
  54. // Setup the WordPress core custom background feature. 
  55. add_theme_support( 'custom-background', apply_filters( 'twentyfifteen_custom_background_args', array( 
  56. 'default-color' => $default_color,  
  57. 'default-attachment' => 'fixed',  
  58. ) ) ); 
  59.  
  60. /** 
  61. * This theme styles the visual editor to resemble the theme style,  
  62. * specifically font, colors, icons, and column width. 
  63. */ 
  64. add_editor_style( array( 'css/editor-style.css', 'genericons/genericons.css', twentyfifteen_fonts_url() ) );