Can’t override the metadesc function

#968382
  • Anthony
    Rank Math free

    Hello,

    I’m trying to override in my functions.php your metadesc function in this file wp-content/plugins/seo-by-rank-math/includes/frontend/class-head.php but it’s not working. Is there a documentation on how to do it ?

    I also tried to remove your action to create mine with the behavior I want but it’s not working either : remove_action(‘rank_math/head’, ‘metadesc’);

    Thank you for your help !

Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the issue you are facing with overriding the metadesc function. Unfortunately, the specific documentation for overriding that function in class-head.php is not provided in the context we have. However, you can try using the following approach to remove the default action and add your custom function:

    1. Remove the existing action: Make sure you are using the correct priority when removing the action. The default priority is usually 10, so you might want to specify that:

      remove_action('rank_math/head', 'metadesc', 10);
    2. Add your custom function: After removing the action, you can add your own function to generate the meta description:

      add_action('rank_math/head', 'your_custom_metadesc_function', 10);
      function your_custom_metadesc_function() {
         // Your custom meta description logic here
      }

    If this does not resolve your issue, please reply to this ticket with more details about what you are trying to achieve, and a human agent from the Rank Math Support team will assist you further. Thank you for raising this concern!

    Sources:
    How to Disable All Rank Math Generated SEO Tags » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.