Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    Thank you for contacting Rank Math support.

    Please share the example filtered WooCommerce URLs so we can check and create the code.

    Meanwhile, here’s the filter to modify the canonical URL to those URLs:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-canonical-url

    Looking forward to helping you.

    Thread Starter raha1988ab

    (@raha1988ab)

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    You can use the following filter to add the self-referencing canonical tag to the filter pages:
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) { $current_url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(strpos($current_url, '?filter')) { return $current_url; } return $canonical; });

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thread Starter raha1988ab

    (@raha1988ab)

    Hello dear @rankmathsupport Rankmath support

    With little modification, the code is working now, thanks a loot

    Would you please give me advices and suggestion? I want to index some filters, but not all of them, what should I do to prevent indexing the rest of filters and attributes?

    Thread Starter raha1988ab

    (@raha1988ab)

    Is it possible to have description dynamically?

    <meta name="description" content="" />

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    You can modify the following line in the code to only set the canonical for some filters: if(strpos($current_url, '?filter')) . Here is an example of how to do it for color and brand filters:

    if(strpos($current_url, '?filter_color') || strpos($current_url, '?filter_brand'))

    You can modify and use the following filter to change the meta description:?https://rankmath.com/kb/filters-hooks-api-developer/#change-meta-description

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thread Starter raha1988ab

    (@raha1988ab)

    Hello @rankmathsupport

    I think there is mis understanding

    I need two things, as you know, in the woocommerce attribute section, there is textarea, if I put something there (for example for a brand of Sony) it will not show in the front-end

    1-but I want to have meta description in my page source, so that link wont help me

    2- I have lots of attributes, around 420, I just want to allow some of them to index not all of them, what should I do?

    Thanks

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    The pages you have shared are not the attribute pages; they are the filter pages generated using attributes. So, there is no way to use the attribute description for their meta description. You can use the filter to set a global description for all the filter pages.

    You can modify the filter and all the filter query parameters to set a self-referencing canonical URL and allow Google to index them.

    Please don’t hesitate to let us know if you need our help with anything else.

    Thread Starter raha1988ab

    (@raha1988ab)

    Hi

    Thanks for answering

    I asked 2 questions but I got answers for just the first

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    Since these are dynamic pages, you can’t directly change their robots meta settings.

    You’ll have to use the example filter code below to selectively index some of the attributes:
    add_filter( 'rank_math/frontend/robots', function( $robots ) { $robots["index"] = 'index'; $robots["follow"] = 'follow'; return $robots; });
    Let us know how that goes. Looking forward to helping you.

    Thread Starter raha1988ab

    (@raha1988ab)

    Hello

    First of all, thank you for all code you give me, I used them and they helped me

    Now I want to index some attributes and set no index to many of my attributes, The url are like this:

    filter_brand=gan
    filter_color=venetian-red
    filter_weights=20kilos

    is there any other code to let me chose what filter index and what filter set to no index?

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @raha1988ab,

    You can expand on the filter we shared above to update the robots meta settings on particular URLs.

    For example, setting a particular set of URLs to “noindex” can be done with the following change to the filter:
    $robots["index"] = 'noindex';

    That statement needs to be added inside an if statement that applies to the particular pages you want to set to “noindex”.

    You can use the same structure for the if statements we shared above for the canonical URLs.

    Don’t hesitate to get in touch if you have any other questions.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Canonical tags for dynamic url crated’ is closed to new replies.