Wish to modify the permalink for the archive page using filters or hooks.

#700889
  • Resolved Deborah Catania
    Rank Math free

    Hi,
    To give you some context my archive page is currently like this :
    http://www.test.com/(subcategory) as I do not wish to have the parent category in the url. The parent Category will only be used when visiting the actual post.

    The url is already set like that however I modified it by functions. I have tried using rank_math/frontend/next_rel_link filter to change the url of the next / prev urls but didn’t work.
    Can you please help with this ?

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

    I’m sorry to hear about the trouble you’re facing with modifying the permalink for the archive page. It seems like you’re trying to remove the parent category from the URL and have already attempted to use the rank_math/frontend/next_rel_link filter to change the URL of the next/prev links without success.

    To modify the permalink for the archive page, you can use the rank_math/frontend/next_rel_link filter. However, it seems that it didn’t work as expected. I’d recommend using the rank_math/frontend/permalink filter instead. This filter allows you to modify the permalink for a post before it is displayed on the frontend.

    Here’s an example of how you can use this filter to modify the permalink:

    add_filter( 'rank_math/frontend/permalink', function( $permalink, $post ) {
        // Your custom logic to modify the permalink here
        return $permalink;
    }, 10, 2 );

    You can add this code to your theme’s functions.php file or a custom plugin. Make sure to replace the comment with your custom logic to modify the permalink.

    If you encounter any issues or need further assistance, please feel free to reach out.

    Best regards.

    Sources:
    How to Optimize a Category Page » Rank Math
    Solving Redirection Issues Using Rank Math SEO Plugin » Rank Math
    Rank Math SEO Filters and Hooks for Developers – Rank Math
    The #1 WordPress SEO Plugin in 2023 – Rank Math
    WordPress Permalink Structure & Changing Individual URLs » Rank Math

    Deborah Catania
    Rank Math free

    The issue I’m facing is only with the next and prev urls

    Deborah Catania
    Rank Math free

    Or how can i disable the next and prev in rank math ?

    Hello,

    You can use this filter to remove/disable the rel next/prev tags:

    /**
     * Allows developers to handle rel="next" / rel="prev" by themselves.
     *
     * @param bool $links_generated Whether or not to handle rel="next" / rel="prev" links.
     */
    add_filter( 'rank_math/frontend/disable_adjacent_rel_links', '__return_true' );

    And here’s a guide to adding the filter to your website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

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

The ticket ‘Wish to modify the permalink for the archive page using filters or hooks.’ is closed to new replies.