Theme Development Code Example

Enqueueing Styles in functions.php:

function enqueue_custom_styles() { wp_enqueue_style('custom-style', get_stylesheet_directory_uri() . '/style.css', array(), '1.0', 'all'); } add_action('wp_enqueue_scripts', 'enqueue_custom_styles');

Adding Theme Support for Post Thumbnails:

add_theme_support('post-thumbnails');

Creating a Custom Navigation Menu:

function register_custom_menu() { register_nav_menu('custom-menu', __('Custom Menu')); } add_action('init', 'register_custom_menu');

Displaying Custom Menu in Theme:

wp_nav_menu(array('theme_location' => 'custom-menu'));

Custom Excerpt Length:

function custom_excerpt_length($length) { return 20; // Adjust the number of words in the excerpt } add_filter('excerpt_length', 'custom_excerpt_length');

Removing WordPress Version Number:

remove_action('wp_head', 'wp_generator');

Custom Background Support:

add_theme_support('custom-background');

Adding Custom Image Sizes:

add_image_size('custom_large', 800, 400, true);

Similar Posts