• Resolved snippet24

    (@snippet24)


    This is happening an all category pages apparently due to a redirection set on the sitemap. Do note I’m not using the build in “Strip Category Base” from RankMath, But instead the following code to strip it.

    function modify_category_link_defaults_proyectos($termlink, $term_id) {
        $ancestors = get_ancestors( $term_id, 'category' );
        $parent_cat = array_values(array_slice($ancestors, -1));
        $term = get_term_by('id', $term_id, 'category');
    
        if ((empty($ancestors)) && ($term->slug == 'proyectos')) {
          $base = get_bloginfo('wpurl');
          $termlink = $base . "/" . $term->slug;
          return $termlink;      
        }
        elseif ((empty($ancestors)) && !($term->slug == 'proyectos')) {
          return $termlink;
        }
        elseif ($parent_cat[0] == 3) {
          $base = get_bloginfo('wpurl');
          $termlink = $base . "/" . $term->slug;
          return $termlink;
        }
        else {
          return $termlink;
        }
    
    }
    
    add_filter( "category_link", "modify_category_link_defaults_proyectos", 10, 2 );

    I did try deactivating this code on functions.php and using the above RankMath preference but it didn’t achieve the same, I could still see the categories with “/proyectos/” in the url (the idea is to only have the post category name).

    The page I need help with: [log in to see the link]

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

    (@rankmathsupport)

    Hello @snippet24,

    Thank you for contacting Rank Math support.

    The filter won’t affect the permalinks included in our plugin’s sitemap. It will still include the default permalink set in WP settings. The Strip Category Base should remove the base from the category URLs, assuming you want to do it for the default post categories.

    Please disable the filter, enable the Strip Category Base option, and save the Permalinks settings of WordPress without making any changes. The option should remove the category base, and the correct URL should be included in the sitemap.

    Let us know how that goes. Looking forward to your update.

    Thread Starter snippet24

    (@snippet24)

    Hi, sorry for the late followup somehow I missed it. I’m afraid doing so I’m getting the same results: “proyectos” is still in the url. Do note when using the filter pages for each category in fact are manually assigned the same url as the category but without the category base.

    Also using the strip tag base from RankMath causes some other pages to not load with warnings such as : Trying to access array offset on value of type null in

    • This reply was modified 9 months, 4 weeks ago by snippet24.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @snippet24,

    If we are understanding this correctly, you are ending up with pages and categories with the same URL because of the removal of the category base.

    In case that’s what is happening, this might cause issues because there can’t be 2 pages with the same URL on any website.

    In such cases, you need to either keep the category base or make sure that you don’t have the same slug for different pages.

    Regarding the error you see, please share the file and line number of that error as well so we can advise further.

    Thank you.

    Thread Starter snippet24

    (@snippet24)

    If we are understanding this correctly, you are ending up with pages and categories with the same URL because of the removal of the category base.

    Not quite, I’m explaining further this:

    1. This is the resultant url for category pages without the custom filter and with RM setting to strip category: https://localhost/wordpress/proyectos/hospitales-y-centros-de-salud/
    2. With filter and no setting (which is the intended behaviour): https://localhost/wordpress/hospitales-y-centros-de-salud/

    So for some reason is not removing the “proyectos” path. But then using the filter messes up the sitemap…

    1. Sitemap without filter and strip setting enabled

    https://drive.google.com/file/d/1jSDiMpiqgtxAkZ8QHJ5QCRof8OrBwS_B/view?usp=sharing

    2. Sitemap with filter and without setting to strip:

    https://drive.google.com/file/d/18wwIyBk82glUJ37JmOglSZ_MUt_GwOkd/view?usp=sharing

    • This reply was modified 9 months, 3 weeks ago by snippet24.
    • This reply was modified 9 months, 3 weeks ago by snippet24.
    Thread Starter snippet24

    (@snippet24)

    Forgot to add I’m using:

    href="<?php echo get_category_link($category) ?>">

    to generate the list of category links

    Thread Starter snippet24

    (@snippet24)

    Ok, sorry I stand corrected indeed is a url path conflict, normally there’s: https://www.hsingenieria.cl/category/servicios/ for that so there’s no conflict. but the “strip base category” preference also strips that “/category/” from the path in addition to the category base, maybe there should be a separated setting so that base category is striped and the second is not.

    If I try to change the url of each category page it changes the slug for the category which affects all the other query code, so it seems I’m unable to do it.

    • This reply was modified 9 months, 3 weeks ago by snippet24.
    • This reply was modified 9 months, 3 weeks ago by snippet24.
    • This reply was modified 9 months, 3 weeks ago by snippet24.
    • This reply was modified 9 months, 3 weeks ago by snippet24.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @snippet24,

    Please confirm if proyectos is a parent category of hospitales-y-centros-de-salud category, or a base.

    Looking forward to helping you.

    Thread Starter snippet24

    (@snippet24)

    Hello, yes is a parent category. In case is useful each post that has the child category checked also has the parent category checked:

    https://drive.google.com/file/d/1XgvpCNue7IW1hNnK8N5s3l9_upvxafTp/view?usp=sharing

    • This reply was modified 9 months, 3 weeks ago by snippet24.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @snippet24,

    The Strip Category Base option only removes the base, not the parent category from the URLs. If you want to remove the parent category slug and include the correct URLs in the sitemap, then you should use a permalink manager plugin instead of using the filter.

    Please do not hesitate to let us know if you need our assistance with anything else.

    Thread Starter snippet24

    (@snippet24)

    Ok I will research is there’s a plugin for that, but theres another point: I dont want to get removed the “/category/” from https://www.hsingenieria.cl/category/servicios/

    • This reply was modified 9 months, 3 weeks ago by snippet24.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @snippet24,

    In that case, you can leave the “Strip Category Base” disabled, and make use of another plugin to manage the category hierarchy you currently have for your pages.

    Looking forward to helping you.

    Thread Starter snippet24

    (@snippet24)

    Or disable category sitemap altogether instead of installing another plugin just for that..

    • This reply was modified 9 months, 2 weeks ago by snippet24.
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @snippet24,

    If you disable the category sitemap, then you will have to submit the category URLs manually to your GSC account or rely on the internal links of your site to get the category pages indexed in the SERPs.

    Please do not hesitate to let us know if you need our assistance with anything else.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Pages not indexed due to redirection on RankMath Sitemap’ is closed to new replies.