WordPress Theme functions.php Code Snippet

I have compiled a list of code snippet that you can use in your functions.php. Other than the framework based shortcodes, and the tweaks, you can use official wordpress tweaks in functions.php.

Theme Support


This code snippet adds the theme support option in wordpress theme settings. You get to change some theme specific changes like blogname, colors and sub heading using theme support.

add_theme_support()

Feed Links

This code snippet enables post and comment RSS feed links to head.

add_theme_support( 'automatic-feed-links' );

Custom Header

This code snippet enables custom header support in theme.

add_theme_support( 'custom-header' );

Custom Background

This code snippet enables custom background support in theme.

add_theme_support( 'custom-background' );

Post Thumbnails

This code snippet enables Post Thumbnails support for a Theme.

add_theme_support( 'post-thumbnails' );

Post Formats

This code snippet enables Post Formats support for a Theme page.


add_post_type_support( 'page', 'post-formats' );


Register Nav Menus

By using this code snippet you can register navigation menus.

register_nav_menus();

Show Nav Menu

Show specific navigation menus using the following snippet code.

wp_nav_menu();

Register Side Bars

When you make custom sidebars, add them using the register sidebar.

register_sidebars();

Add Editor Style

Using the following code, add the editor style.

add_editor_style();

These are the functions that you can add in your functions.php while developing theme. Learn how you can make WordPress theme from HTML template. Please feel free to comment and let me know if there are additional code snippets that you can use.