How to remove a Meta Tag created by a Wordpress plugin?

Asked

Viewed 807 times

3

How can I remove a meta tag in Wordpress?

More precisely the meta tag generator created by Visual Composer.

<meta name="generator" content="Powered by Visual Composer - drag and drop page builder for WordPress."/>
  • Have you tried commenting on the line that adds this tag on source of the plugin?

  • 1

    As Visual Composer is a premium plugin and it will certainly be difficult to find someone who uses it here and who knows how to respond, I think you should use your consumer right and talk to who sold it to you in Codecanyon, because when you buy you also earn right to have support.

  • You can post the code of the plugin that generates this tag?

  • I have, and so far I haven’t found.

2 answers

4


It is necessary to locate the hook responsible for printing this line in HTML. Usually, it is an action attached to wp_head. After that, we use remove_action or remove_filter to remove the hook.

We will have to pay attention if the hook is inside another and what the priority of each one. If the plugin/theme uses something like this:

add_action( $nome_do_hook, $funcao_de_retorno, $prioridade, $parametros );
add_action( 'wp_head', 'funcao_de_retorno', 11, 2 );

The remove_action will be:

remove_action( 'wp_head', 'funcao_de_retorno', 11 );

If the priority is 10 or it is not declared, it is not necessary to put it, because 10 is the default value. Parameters do not matter.

The thing gets a little more complex when the plugin uses OOP. Some programmers leave the objects Anonimos, causing this kind of problem. But in the case of Visual Composer, it’s easy to access the class:

add_action( 'init', function() 
{
    if( class_exists( 'WPBakeryVisualComposer') )
        remove_action( 'wp_head', array( WPBakeryVisualComposer::getInstance(), 'addMetaData' ) );
}, 11 ); // <-- a prioridade padrão não teve efeito, usando uma menos importante deu certo

Searching for Powered by within the plugin files, we see that this is added by $this->composer->addAction('wp_head', 'addMetaData');, and that code is inside a init with standard priority.

  • Worked round! I added to a plugin with several plugins all in one that you have created for me, rsrsrs.... Thanks Bras! You are 10.

  • I gather several in one.

  • 1

    This plugin of mine was born there: joining several utilities within a single plugin ;)

  • Very toop! You’re the guy!

  • I didn’t know this plugin, great!

1

The @brasofilo response was correct, however, it seems that they changed how to register the action and it is necessary to change:

remove_action( 'wp_head', array( WPBakeryVisualComposer::getInstance(), 'addMetaData' ) );

for:

remove_action('wp_head', array(visual_composer(), 'addMetaData'));

With me gave error and found this solution in their support on Codecanyon.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.