Canonical URL

  • 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)
  • 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

    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.

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

You must be logged in to reply to this ticket.