wp-content/themes/twentyten/functions.php
TwentyTen functions and definitions
Sets up the theme and provides some helper functions. Some helper functions are used in the theme as custom template tags. Others are attached to action and filter hooks in WordPress to change core functionality.
The first function, twentyten_setup(), sets up the theme by registering support for various features in WordPress, such as post thumbnails, navigation menus, and the like.
When using a child theme (see http://codex.wordpress.org/Theme_Development and http://codex.wordpress.org/Child_Themes), you can override certain functions (those wrapped in a function_exists() call) by defining them first in your child theme's functions.php file. The child theme's functions.php file is included before the parent theme's file, so the child theme functions would be used.
Functions that are not pluggable (not wrapped in function_exists()) are instead attached to a filter or action hook. The hook can be removed by using remove_action() or remove_filter() and you can attach your own function to the hook.
We can remove the parent theme's hook only after it is attached, which means we need to wait until setting up the child theme:
add_action( 'after_setup_theme', 'my_child_theme_setup' );
function my_child_theme_setup() {
// We are providing our own filter for excerpt_length (or using the unfiltered value)
remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
...
}
For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
- package
- WordPress
- since
- Twenty Ten 1.0
- subpackage
- Twenty_Ten
Functions
twentyten_admin_header_style(
)
:
Referenced via add_custom_image_header() in twentyten_setup().
- since
- Twenty Ten 1.0
twentyten_auto_excerpt_more(
$more
)
:
stringTo override this in a child theme, remove the filter and add your own function tied to the excerpt_more filter hook.
| Name | Type | Description |
|---|---|---|
| $more |
| Type | Description |
|---|---|
| string |
- since
- Twenty Ten 1.0
twentyten_comment(
$comment, $args, $depth
)
:
To override this walker in a child theme without modifying the comments template simply create your own twentyten_comment(), and that function will be used instead.
Used as a callback by wp_list_comments() for displaying the comments.
| Name | Type | Description |
|---|---|---|
| $comment | ||
| $args | ||
| $depth |
- since
- Twenty Ten 1.0
twentyten_continue_reading_link(
)
:
string| Type | Description |
|---|---|
| string |
- since
- Twenty Ten 1.0
twentyten_custom_excerpt_more(
$output
)
:
stringTo override this link in a child theme, remove the filter and add your own function tied to the get_the_excerpt filter hook.
| Name | Type | Description |
|---|---|---|
| $output |
| Type | Description |
|---|---|
| string |
- since
- Twenty Ten 1.0
twentyten_excerpt_length(
$length
)
:
intTo override this length in a child theme, remove the filter and add your own function tied to the excerpt_length filter hook.
| Name | Type | Description |
|---|---|---|
| $length |
| Type | Description |
|---|---|
| int |
- since
- Twenty Ten 1.0
twentyten_page_menu_args(
$args
)
:
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.
| Name | Type | Description |
|---|---|---|
| $args |
- since
- Twenty Ten 1.0
twentyten_posted_in(
)
:
- since
- Twenty Ten 1.0
twentyten_posted_on(
)
:
- since
- Twenty Ten 1.0
twentyten_remove_gallery_css(
$css
)
:
stringThis function is no longer needed or used. Use the use_default_gallery_style filter instead, as seen above.
| Name | Type | Description |
|---|---|---|
| $css |
| Type | Description |
|---|---|
| string |
- deprecated
- Deprecated in Twenty Ten 1.2 for WordPress 3.1
- since
- Twenty Ten 1.0
twentyten_remove_recent_comments_style(
)
:
To override this in a child theme, remove the filter and optionally add your own function tied to the widgets_init action hook.
This function uses a filter (show_recent_comments_widget_style) new in WordPress 3.1 to remove the default style. Using Twenty Ten 1.2 in WordPress 3.0 will show the styles, but they won't have any effect on the widget in default Twenty Ten styling.
- since
- Twenty Ten 1.0
twentyten_setup(
)
:
Note that this function is hooked into the after_setup_theme hook, which runs before the init hook. The init hook is too late for some features, such as indicating support post thumbnails.
To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's functions.php file.
- since
- Twenty Ten 1.0
- uses
- \add_theme_support()
- uses
- \register_nav_menus()
- uses
- \add_custom_background()
- uses
- \add_editor_style()
- uses
- \load_theme_textdomain()
- uses
- \add_custom_image_header()
- uses
- \register_default_headers()
- uses
- \set_post_thumbnail_size()
twentyten_widgets_init(
)
:
To override twentyten_widgets_init() in a child theme, remove the action hook and add your own function tied to the init hook.
- since
- Twenty Ten 1.0
- uses
- \register_sidebar