Created
April 10, 2015 21:29
-
-
Save Caspert/26f51bf1bf32eb95fc7a to your computer and use it in GitHub Desktop.
Simple functions.php theme file for WordPress custom themes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define and creating constants | |
define('TEMPPATH', get_bloginfo('stylesheet_directory')); // Path to the theme directory | |
define('IMAGES', TEMPPATH. "/images"); // IMAGES uses TEMPPATH and appends the image folder | |
// Add theme support for custom menu | |
add_theme_support('nav-menus'); | |
if(function_exists('register_nav_menu')) { | |
// This theme uses wp_nav_menu() in one location. | |
register_nav_menu( 'primary-menu', __('Primary Menu')); | |
} | |
// Add WALKER custom class to menu | |
function add_anchor_to_nav($menu) { | |
remove_filter('wp_nav_menu_items', 'add_anchor_to_nav', 10, 2); | |
$pat = '(<nav[^>]+?>)(.*)'; | |
$menu = preg_replace('|'.$pat.'|','$1<a href="#" class="close">X</a>$2', $menu); | |
return $menu; | |
} | |
add_filter('wp_nav_menu', 'add_anchor_to_nav', 10, 2); | |
// Add sidebar support | |
if(function_exists('register_sidebar')) { | |
register_sidebar( array( | |
'name' => __('Sidebar', 'sidebar'), | |
'id' => 'widget-area', | |
'description' => __('The widget area', 'dir'), | |
'before_widget' => '<li class="grid_4 widget">', | |
'after_widget' => '</li>', | |
'before_title' => '<h2>', | |
'after_title' => '</h2>', | |
)); | |
} | |
// Add featured image support | |
if(function_exists('add_theme_support')) { | |
add_theme_support('post-thumbnails'); | |
set_post_thumbnail_size(260, 150); | |
add_image_size('thumbnail-post', 300, 0, true); // Post thumbnails | |
add_image_size('thumbnail-archive', 680, 180, true); // Archive thumbnails | |
add_image_size('thumbnail-pages', 300, 0, true); // Pages thumbnails | |
} | |
require_once('wp-theme-options/theme-settings.php'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment