Canonical URL

#71045
  • Resolved Tristan O’Donnell
    Rank Math free

    Hi,

    I am using Geodirectory and within its categories it is designed to have different descriptions based on location thereby producing location relevant results. The problem is the location specific pages won’t appear in the search results as the canonical URL is the main category URL which is declared by Rank Math.

    Is there a way to prevent the canonical URL being submitted by Rank Math for Geodirectory categories?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 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.

    Meanwhile the canonical is automatically added in your site by Rank Math, you could use the following filter (you will need to customize it a little to check if you are in the category you don’t want the Rank Math’s canonical) to remove the Rank Math canonical there:

    add_action( 'wp_head', function(){
    	if( /* Check here if you are inside the category where you don't want the canonical */) {
    		remove_all_actions( 'rank_math/head' );
    		add_action( 'wp_head', '_wp_render_title_tag', 2 );
    	}
    }, 1 );

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Hi,

    Thanks, can I add a filter to include all Geodirectory categories or do they have to be done individually? Where would I add this filter?

    Thanks

    Alberto
    Rank Math business

    Hello,

    You could code the conditional to include all the categories and their posts so you only need to add the filter once.

    You will need to add it at the end of your current theme’s functions.php file.

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Canonical URL’ is closed to new replies.