:) This is the core <%= theme_id %> file where most of the main functions & features reside. If you have any custom functions, it's best to put them in the functions.php file. Developed by: <%= config[:author] %> URL: <%= config[:author_uri] %> */ /********************* LAUNCH <%= theme_id %> Let's fire off all the functions and tools. I put it up here so it's right up top and clean. *********************/ // we're firing all out initial functions at the start add_action('after_setup_theme','<%= theme_id %>_ahoy', 16); function <%= theme_id %>_ahoy() { // launching operation cleanup add_action('init', '<%= theme_id %>_head_cleanup'); // remove WP version from RSS add_filter('the_generator', '<%= theme_id %>_rss_version'); // remove pesky injected css for recent comments widget add_filter( 'wp_head', '<%= theme_id %>_remove_wp_widget_recent_comments_style', 1 ); // clean up comment styles in the head add_action('wp_head', '<%= theme_id %>_remove_recent_comments_style', 1); // clean up gallery output in wp add_filter('gallery_style', '<%= theme_id %>_gallery_style'); // enqueue base scripts and styles add_action('wp_enqueue_scripts', '<%= theme_id %>_scripts_and_styles', 999); // ie conditional wrapper // launching this stuff after theme setup <%= theme_id %>_theme_support(); // adding sidebars to Wordpress (these are created in functions.php) add_action( 'widgets_init', '<%= theme_id %>_register_sidebars' ); // adding the <%= theme_id %> search form (created in functions.php) add_filter( 'get_search_form', '<%= theme_id %>_wpsearch' ); // cleaning up random code around images add_filter('the_content', '<%= theme_id %>_filter_ptags_on_images'); // cleaning up excerpt add_filter('excerpt_more', '<%= theme_id %>_excerpt_more'); } /* end <%= theme_id %> ahoy */ /********************* WP_HEAD GOODNESS The default wordpress head is a mess. Let's clean it up by removing all the junk we don't need. *********************/ function <%= theme_id %>_head_cleanup() { // category feeds // remove_action( 'wp_head', 'feed_links_extra', 3 ); // post and comment feeds // remove_action( 'wp_head', 'feed_links', 2 ); // EditURI link remove_action( 'wp_head', 'rsd_link' ); // windows live writer remove_action( 'wp_head', 'wlwmanifest_link' ); // index link remove_action( 'wp_head', 'index_rel_link' ); // previous link remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // start link remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // links for adjacent posts remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // WP version remove_action( 'wp_head', 'wp_generator' ); // remove WP version from css add_filter( 'style_loader_src', '<%= theme_id %>_remove_wp_ver_css_js', 9999 ); // remove Wp version from scripts add_filter( 'script_loader_src', '<%= theme_id %>_remove_wp_ver_css_js', 9999 ); } /* end <%= theme_id %> head cleanup */ // remove WP version from RSS function <%= theme_id %>_rss_version() { return ''; } // remove WP version from scripts function <%= theme_id %>_remove_wp_ver_css_js( $src ) { if ( strpos( $src, 'ver=' ) ) $src = remove_query_arg( 'ver', $src ); return $src; } // remove injected CSS for recent comments widget function <%= theme_id %>_remove_wp_widget_recent_comments_style() { if ( has_filter('wp_head', 'wp_widget_recent_comments_style') ) { remove_filter('wp_head', 'wp_widget_recent_comments_style' ); } } // remove injected CSS from recent comments widget function <%= theme_id %>_remove_recent_comments_style() { global $wp_widget_factory; if (isset($wp_widget_factory->widgets['WP_Widget_Recent_Comments'])) { remove_action('wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')); } } // remove injected CSS from gallery function <%= theme_id %>_gallery_style($css) { return preg_replace("!!s", '', $css); } /********************* SCRIPTS & ENQUEUEING *********************/ // loading modernizr and jquery, and reply script function <%= theme_id %>_scripts_and_styles() { global $wp_styles; // call global $wp_styles variable to add conditional wrapper around ie stylesheet the WordPress way if (!is_admin()) { // modernizr (without media query polyfill) wp_register_script( '<%= theme_id %>-modernizr', get_stylesheet_directory_uri() . '/library/js/libs/modernizr.custom.min.js', array(), '2.5.3', false ); // register main stylesheet wp_register_style( '<%= theme_id %>-stylesheet', get_stylesheet_directory_uri() . '/library/css/style.css', array(), '', 'all' ); // ie-only style sheet wp_register_style( '<%= theme_id %>-ie-only', get_stylesheet_directory_uri() . '/library/css/ie.css', array(), '' ); // comment reply script for threaded comments if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) { wp_enqueue_script( 'comment-reply' ); } //adding scripts file in the footer wp_register_script( '<%= theme_id %>-js', get_stylesheet_directory_uri() . '/library/js/scripts.js', array( 'jquery' ), '', true ); // enqueue styles and scripts wp_enqueue_script( '<%= theme_id %>-modernizr' ); wp_enqueue_style( '<%= theme_id %>-stylesheet' ); wp_enqueue_style('<%= theme_id %>-ie-only'); $wp_styles->add_data( '<%= theme_id %>-ie-only', 'conditional', 'lt IE 9' ); // add conditional wrapper around ie stylesheet /* I recommend using a plugin to call jQuery using the google cdn. That way it stays cached and your site will load faster. */ wp_enqueue_script( 'jquery' ); wp_enqueue_script( '<%= theme_id %>-js' ); } } /********************* THEME SUPPORT *********************/ // Adding WP 3+ Functions & Theme Support function <%= theme_id %>_theme_support() { // wp thumbnails (sizes handled in functions.php) add_theme_support('post-thumbnails'); // default thumb size set_post_thumbnail_size(125, 125, true); // wp custom background (thx to @bransonwerner for update) add_theme_support( 'custom-background', array( 'default-image' => '', // background image default 'default-color' => '', // background color default (dont add the #) 'wp-head-callback' => '_custom_background_cb', 'admin-head-callback' => '', 'admin-preview-callback' => '' ) ); // rss thingy add_theme_support('automatic-feed-links'); // to add header image support go here: http://themble.com/support/adding-header-background-image-support/ // adding post format support add_theme_support( 'post-formats', array( 'aside', // title less blurb 'gallery', // gallery of images 'link', // quick link to other site 'image', // an image 'quote', // a quick quote 'status', // a Facebook like status update 'video', // video 'audio', // audio 'chat' // chat transcript ) ); // wp menus add_theme_support( 'menus' ); // registering wp3+ menus register_nav_menus( array( 'main-nav' => __( 'The Main Menu', '<%= theme_id %>theme' ), // main nav in header 'footer-links' => __( 'Footer Links', '<%= theme_id %>theme' ) // secondary nav in footer ) ); } /* end <%= theme_id %> theme support */ /********************* MENUS & NAVIGATION *********************/ // the main menu function <%= theme_id %>_main_nav() { // display the wp3 menu if available wp_nav_menu(array( 'container' => false, // remove nav container 'container_class' => 'menu clearfix', // class of container (should you choose to use it) 'menu' => __( 'The Main Menu', '<%= theme_id %>theme' ), // nav name 'menu_class' => 'nav top-nav clearfix', // adding custom nav class 'theme_location' => 'main-nav', // where it's located in the theme 'before' => '', // before the menu 'after' => '', // after the menu 'link_before' => '', // before each link 'link_after' => '', // after each link 'depth' => 0, // limit the depth of the nav 'fallback_cb' => '<%= theme_id %>_main_nav_fallback' // fallback function )); } /* end <%= theme_id %> main nav */ // the footer menu (should you choose to use one) function <%= theme_id %>_footer_links() { // display the wp3 menu if available wp_nav_menu(array( 'container' => '', // remove nav container 'container_class' => 'footer-links clearfix', // class of container (should you choose to use it) 'menu' => __( 'Footer Links', '<%= theme_id %>theme' ), // nav name 'menu_class' => 'nav footer-nav clearfix', // adding custom nav class 'theme_location' => 'footer-links', // where it's located in the theme 'before' => '', // before the menu 'after' => '', // after the menu 'link_before' => '', // before each link 'link_after' => '', // after each link 'depth' => 0, // limit the depth of the nav 'fallback_cb' => '<%= theme_id %>_footer_links_fallback' // fallback function )); } /* end <%= theme_id %> footer link */ // this is the fallback for header menu function <%= theme_id %>_main_nav_fallback() { wp_page_menu( array( 'show_home' => true, 'menu_class' => 'nav top-nav clearfix', // adding custom nav class 'include' => '', 'exclude' => '', 'echo' => true, 'link_before' => '', // before each link 'link_after' => '' // after each link ) ); } // this is the fallback for footer menu function <%= theme_id %>_footer_links_fallback() { /* you can put a default here if you like */ } /********************* RELATED POSTS FUNCTION *********************/ // Related Posts Function (call using <%= theme_id %>_related_posts(); ) function <%= theme_id %>_related_posts() { echo '