Categories
WordPress Templates

Basic WordPress functions.php Code

For a Block Theme:

This will enqueue your styles.css file, making the styles that you write there available to WordPress.

It is recommended to put as much of your styling into theme.json as possible.

However, there is still things that cannot be done in theme.json yet, and the Custom CSS area of theme.json is recommended only for small changes.

<?php

// Change all instances of THEME to your theme name.
 
function THEME_scripts_styles(){
   wp_enqueue_style('THEME_style', get_stylesheet_uri());
}
 
add_action('wp_enqueue_scripts','THEME_scripts_styles');

For a Classic Theme:

<?php

// Change all instances of THEMENAME to your theme name.
if ( ! function_exists( 'THEMENAME_setup' ) ) :
 
   function THEMENAME_setup() {
     add_theme_support( 'automatic-feed-links' );
     add_theme_support( 'title-tag' );
     add_theme_support( 'post-thumbnails' );
   }
 
endif;
 
add_action('after_setup_theme', 'THEMENAME_setup');
 
function THEMENAME_scripts_styles(){
   wp_enqueue_style('THEMENAME_style', get_stylesheet_uri());
}
 
add_action('wp_enqueue_scripts', 'THEMENAME_scripts_styles');