I have read up on this and tried it myself, but I cannot seem to figure out how to override a parent theme function using my child theme.

I need to know what I am doing wrong (and I am sure there are several wrong things).

Here is the function in the parent theme:

function html5_insert_image($html, $id, $caption, $title, $align, $url, $size, $alt) {
    $url = wp_get_attachment_url($id);
    $src = wp_get_attachment_image_src( $id, $size, false );
    $html5 = "<figure class='align$align'><a href='$url'>";
    $html5 .= "<img src='$src[0]' alt='$alt' />";
    if ($caption) { 
        $html5 .= "<figcaption>$caption</figcaption>";
    $html5 .= "</a></figure>";
    return $html5;
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );

Here is the function in the child theme:

function remove_html5_insert_image(){

1 Answer 1


First, you are confused. It is not the same "override a function" that remove a filter. Assuming that you want to remove a filter, I think that your code should be:

function remove_html5_insert_image(){
    remove_filter('image_send_to_editor','html5_insert_image', 10);

Note that the filter tag and the priority argument in remove_filter must match the filter tag and the priority defined in the filter you want to remove.

Anyway, There is no need of that function since WP 3.9, use this instead to make Wordpress use figure and figcaption in the output of captions:

add_action( 'after_setup_theme', 'cyb_theme_setup' );
function tbn_theme_setup() {
    // See more in http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
    add_theme_support( 'html5', array( 'caption' ) );
  • Indeed, I probably was confused. This is working for me, thank you so much!
    – Joseph
    Commented Aug 14, 2014 at 18:32
  • You are wellcome ;)
    – cybmeta
    Commented Aug 15, 2014 at 9:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.