BUG Code Remove Canonical

#149495
  • Hi,

    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
    //create conditional here to check for the tax page
    if(condition){
    return ”;
    }
    return $canonical;
    });

    [11-Feb-2021 10:58:35 UTC] PHP Warning: Use of undefined constant condition – assumed ‘condition’ (this will throw an Error in a future version of PHP) in /home/opbina/public_html/wp-includes/functions.php on line 7990

    Line 7990:
    if(condition){

    Any ideas how to use this code without error? Your other rank match codes didn’t work for me, only this one I put here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for the delay and for any inconvenience this issue may have caused you.

    To remove all canonical URLs using the filter, use it as follows in your theme’s functions.php file:

    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	$canonical = "";
    	return $canonical;
    });

    I hope that helps. Thank you, and looking forward to your update.

    It worked well, thanks for your seriousness, when I have time to answer my last point on this ticket (it is the last thing I am missing).
    Thank you so much for all the help!

    https://support.rankmath.com/ticket/remove-meta-name-robots-all/#post-149319

    Hello,

    We will get back to you on your other ticket as well.

    We are super happy that this issue is already resolved. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘BUG Code Remove Canonical’ is closed to new replies.