Stop Rank Math Titles on Select Pages – ERROR

#68091
  • Resolved Our DFW
    Rank Math free

    I have another plugin that delivers its results to certain pages (page id: 7952 and page id: 5072). I have added the following code to my functions.php to block Rank Math from overwriting my titles so I can use their default SEO title options.

    // BLOCKS RANK MATH FROM CHANGING THE URL TITLES FOR PROPERTIES
    add_action( 'wp_head', 'rankmath_disable_features',1);
    function rankmath_disable_features() {
    $page_id = array('5072','7952');
    if( is_page( $page_id) ) {
        remove_all_actions( 'rank_math/head');
    }
    }
    

    The problem is that my titles are definitely blocked from those page id’s BUT they are completely blank. If I turn off your plugin, my titles re-appear just fine.

    What am I doing wrong with my code?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Page ID arrays should be added like this:

    $page_id = array(5072,7952);

    As you can see here: https://developer.wordpress.org/reference/functions/is_page/#user-contributed-notes

    Looking forward to helping you. Thank you.

    ​​​​​​​

    I tried that code. It gave me the same error. It completely removed the title from the page.

    When I delete your plugin, the problem is solved.

    Hello,
    You can try following filter code to prevent Rank Math from changing the Title on your specified pages.

    
    
    add_filter( 'rank_math/frontend/title', function( $title ) {
        if ( IS_PAGE_CONDITION ) {
            return '';
        }
        
        return $title;
    });
    

    Looking forward to helping you. Thank you.

    ​​​​​​

    Do I add that code in addition to the previous code, or replace the old code with this new one?

    Alberto
    Rank Math business

    Hello,

    You should replace the old one with this one. Please try it and let us know if that solves your issue.

    Looking forward to help you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Stop Rank Math Titles on Select Pages – ERROR’ is closed to new replies.