Andres Molina Perez-Tome Andres Molina Perez-Tome - 1 month ago 6x
PHP Question

Disable a theme function in from a child theme functions.php in wordpress

I was having a problem with my theme in wordpress, that was showing its own og:meta descriptions on my theme, so it gets duplicated due to all in one seo plugin.

I wanted to disable the ones from the theme, but i did not know how, so i manage to find the function on the php file which is triggering this to show on the website, but i dont know how to disable it from the functions.php or my child theme, so it does not get overriten when update. The function in question is the following

// Open Graph Meta
function aurum_wp_head_open_graph_meta() {
global $post;

// Only show if open graph meta is allowed
if ( ! apply_filters( 'aurum_open_graph_meta', true ) ) {

// Do not show open graph meta on single posts
if ( ! is_singular() ) {

$image = '';

if ( has_post_thumbnail( $post->ID ) ) {
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'original' );
$image = esc_attr( $featured_image[0] );


<meta property="og:type" content="article"/>
<meta property="og:title" content="<?php echo esc_attr( get_the_title() ); ?>"/>
<meta property="og:url" content="<?php echo esc_url( get_permalink() ); ?>"/>
<meta property="og:site_name" content="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>"/>
<meta property="og:description" content="<?php echo esc_attr( get_the_excerpt() ); ?>"/>

<?php if ( '' != $image ) : ?>
<meta property="og:image" content="<?php echo $image; ?>"/>
<?php endif;

add_action( 'wp_head', 'aurum_wp_head_open_graph_meta', 5 );

Thanks a lot in advance.


You could try removing the action that the function creates.

add_action( 'init', 'remove_my_action' );
    function remove_my_action(){
      remove_action( 'wp_head', 'aurum_wp_head_open_graph_meta', 5 );

Note that the action needs to be removed on the same $priority as it was added (in your case '5'). Try adding the above code to your child theme's functions.php file and see if it removes the action.

Some additional reading regarding adding/removing actions in WordPress: