我真的被困在这一点上了-下面是这篇文章:
How to override parent functions in child themes
我不知道如何重写二十个十的set\\u post\\u thumbnail\\u size()函数。我在下面列出了我正在执行的其他重写的代码,但当我将其添加到函数twentyten\\u child\\u theme\\u setup()时,什么都没有发生:
set_post_thumbnail_size( array(100,100) , array("class" => "alignleft post_thumbnail"), true );
我在循环中插入缩略图,如下所示:
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) {
the_post_thumbnail(array(100,100), array("class" => "alignleft post_thumbnail"));
} else { ?>
<img src="<?php echo bloginfo(\'stylesheet_directory\'); ?>/images/thumb-default.jpg" alt="thumb-default" width="100" height="100" />
<?php } ?>
下面是我的函数-有人能帮我重写这个讨厌的函数吗?
谢谢
osu
function twentyten_child_theme_setup() {
// OVERRIDE SIDEBAR GENERATION!
function osu_twentyten_widgets_init() {
// Siedbar 1, located on LHS sidebar
register_sidebar( array(
\'name\' => __( \'Primary Widget Area\', \'twentyten-child\' ),
\'id\' => \'primary-widget-area\',
\'description\' => __( \'The primary widget area where the navigation goes\', \'twentyten-child\' ),
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
// Area 2, located on RHS sidebar
register_sidebar( array(
\'name\' => __( \'Secondary Widget Area\', \'twentyten-child\' ),
\'id\' => \'secondary-widget-area\',
\'description\' => __( \'The secondary widget area\', \'twentyten-child\' ),
\'before_widget\' => \'<li id="%1$s" class="widget-container %2$s">\',
\'after_widget\' => \'</li>\',
\'before_title\' => \'<h3 class="widget-title">\',
\'after_title\' => \'</h3>\',
) );
}
/* Deregister sidebar in parent */
remove_action( \'widgets_init\', \'twentyten_widgets_init\' );
/** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
add_action( \'widgets_init\', \'osu_twentyten_widgets_init\' );
// OVERRIDE EXCERPT READ MORE LINK
function osu_readon_link() {
return \' <a href="\'. get_permalink() . \'" class="readmore">\' . __( \'Read More\', \'twentyten-child\' ) . \'</a>\';
}
// Function to override
function osu_twentyten_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= osu_readon_link();
}
return $output;
}
remove_filter( \'get_the_excerpt\', \'twentyten_custom_excerpt_more\' );
add_filter( \'get_the_excerpt\', \'osu_twentyten_custom_excerpt_more\' );
}
/* IMPORTANT: Run the code for parent function overrides (involving hooks and filters) after theme setup! */
add_action( \'after_setup_theme\', \'twentyten_child_theme_setup\' );