How to change parent permalink?

by mrmut   Last Updated March 23, 2019 03:08 AM

I have a theme with hardcoded permalink structure for some posts. Those posts open with

site.com/parent/page

structure.

I created a filter that replaces the link from "site.com/parent/page" to "site.com/newparent/page" in functions.php with:

add_action('init', 'change_slug_of_post_type_parent', 20);
function change_slug_of_post_type_parent()
{   
$args = get_post_type_object("parent");
$args->rewrite["slug"] = "newparent";
register_post_type($args->name, $args);
}

Links are now generated OK, but when I click on them, the page doesn't load.

Can someone please help? I am sure this is easy fix, but I cant get around it. I am new to wordpress programming (I used GSCMS, and CMSGS before).

Thanks



Answers 1


Benoti posted the solution in comments: "Did you flush rewrite rules?"

How to flush: https://www.webhostinghero.com/3-ways-to-flush-the-rewrite-cache-in-wordpress/

mrmut
mrmut
October 20, 2016 06:28 AM

Related Questions


how to change a theme slug

Updated March 24, 2017 07:08 AM


How to get Plugin Slugs?

Updated May 26, 2019 17:08 PM