Pintsize functions.php

functions.php

A theme can optionally use a functions file, which resides in the theme subdirectory and is named functions.php. This file basically acts like a plugin, and if it is present in the theme you are using, it is automatically loaded during WordPress initialization (both for admin pages and external pages). Suggested uses for this file:

  • Define functions used in several template files of your theme.
  • Enable features such as post thumbnails, custom header and background, and navigation menus.
  • Set up an options menu, giving site owners options for colors, styles, and other aspects of your theme.

The Pintsize theme contains a functions.php file that defines some of these features. Since functions.php basically functions as a plugin, the Function_Reference list is the best place to go for more information on what you can do with this file.

<?php
	
// Add RSS links to <head> section
automatic_feed_links();
	
// Load jQuery
if ( !is_admin() ) {
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"), false);
   wp_enqueue_script('jquery');
}
	
// Clean up the <head>
function removeHeadLinks() {
  	remove_action('wp_head', 'rsd_link');
    	remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'removeHeadLinks');
remove_action('wp_head', 'wp_generator');

// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 130, true ); // Normal post thumbnails

// Register custom navigation menu
if ( function_exists( 'register_nav_menus' ) ) {
	register_nav_menus(
		array(
		  'primary-menu' => 'Primary Menu'
		)
	);
}

/**
 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
 *
 * To override this in a child theme, remove the filter and optionally add
 * your own function tied to the wp_page_menu_args filter hook.
 *
 * @since Twenty Ten 1.0
*/
function twentyten_page_menu_args( $args ) {
   $args['show_home'] = true;
   return $args; }
add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );

// Filter Out Extraneous Class/IDs on Generated Code
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var) {
   return is_array($var) ? array_intersect($var, array('current-menu-item')) : ''; 
}

// Set up sidebar parameter options    
if (function_exists('register_sidebar')) {
	register_sidebar(array(
    		'name' => 'Sidebar Widgets',
    		'id'   => 'sidebar-widgets',
    		'description'   => 'These are widgets for the sidebar.',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h2>',
    		'after_title'   => '</h2>'
    	));
}

add_theme_support( 'post-formats', 
   array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'audio', 'chat', 'video')); 
   // Add 3.1 post format theme support.

?>

Next, style.css

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s