How to remove set_post_thumbnail_size() in child themes?

I’m really stuck on this – this follows on from this post:

How to override parent functions in child themes

Read More

I can’t figure out how to override Twenty Ten’s set_post_thumbnail_size() function. I’ve put my code below for the other overrides I’m doing, but nothing happens when I add this to my function twentyten_child_theme_setup():

set_post_thumbnail_size( array(100,100) , array("class" => "alignleft post_thumbnail"), true );

I’m inserting the thumbnail in my loop like this:

<?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 } ?>

Here’s my function below – can anyone help me override this pesky function?

Thanks,

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' );

Related posts

Leave a Reply

1 comment

  1. What exactly do you mean by nothing happens ?

    Technically you don’t need to remove set_post_thumbnail_size(), as I understand from code – simply making your own call later will overwrite size.

    There are two ways you can handle this:

    1. Adjust your setup function to later priority. Child theme is processed before parent theme. So when you hook with default priority – setup functions are also executed in that order. So add_action( 'after_setup_theme', 'twentyten_child_theme_setup', 11 );

    2. Plug your own twentyten_setup() function. It is wraped in if ( ! function_exists( 'twentyten_setup' ) ) condition in Twenty Ten. So simply copy it to your theme and make changes you need – your version will run instead of original one.