unable to edit amp category slug

Posted in: Newspaper
Post count: 68

Hi,
Currently, I’m having permalink structure as sitename/%%postname% but this structure is not working properly for google news index. So for particular category alone, I have added the category slug in the URL with the below code:

code:

add_action(‘init’, function()
{
add_rewrite_rule(‘^sports/([^/]+)/?$’, ‘index.php?name=$matches[1]’, ‘top’);
}, 10, 0);

add_filter(‘post_link’, function($post_link, $post, $leave_name = false, $sample = false)
{
if ( has_category(‘sports’, $post) ) {
$post_link = str_replace(‘/’ . $post->post_name, ‘/sports/’ . $post->post_name, $post_link);
}

return $post_link;

}, 10, 4);

So now when I checked sports category then sports slug is adding properly in the URL. Now the problem is, it is not working for amp pages.

For example:
If my URL is abc.dom/sports/sachin-batting
My amp URL should be abc.dom/sports/sachin-batting/amp but this URL is not working. This is working only if I entered the old pattern i.e bc.dom/sachin-batting/amp

So I kindly request you provide some suggestion on achieving this in amp page.

Post count: 35449

Hi,

Please try the custom permalinks ( img ) or maybe you can try with Youst SEO plugin
How to change your WordPress permalink structure -> https://yoast.com/?s=permalinks
Hope this will help you.

Thank you for your understanding.

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.