Support » Plugin: Permalink Manager Lite » Remove Parent from URL

  • Resolved patrickbolby

    (@patrickbolby)


    So, for hours I tried to solve this. Now I feel it’s okay that I seek support. I really don’t know how to solve this:

    So all I want is just a clean URL made from the title. So the structure should just be site.dk/title-name. And all my settings are set to be like this. But for some reason it keeps adding mig parent page and “/forside” (means homepage) before the title name when i press “publish” Sooo annoying please help me remove this!

    I bulk update pages so an ideal solution for me is not to manually edit each url-slug after it’s saved.

    Seems like some content has been removed here. At least the -url ID does not lead to anything and on this page I could not find what i was looking for. https://permalinkmanager.pro/docs/basics/bulk-edit-custom-permalinks/#remove-parent-slugs/

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @patrickbolby,

    The page that you are looking for is now moved to a separate article:

    https://permalinkmanager.pro/docs/tutorials/wordpress-permalinks-structure/#6-how-to-remove-parent-slugs-for-shorter-urls

    If you would like to make all the pages flat, you can replace in the Permastructure settings for pages the original %pagename% tag with %postname_flat%.

    Alternatively you can get rid of /forside/ prefix from the default permalink for new pages using a code snippet:

    function pm_remove_forside_prefix( $default_uri, $native_slug, $post, $slug, $native_uri ) {
    	return str_replace( 'forside/', '', $default_uri );
    }
    add_filter( 'permalink_manager_filter_default_post_uri', 'pm_remove_forside_prefix', 10, 5 );

    Best regards,
    Maciej

    • This reply was modified 3 months ago by Maciej Bis.
    • This reply was modified 3 months ago by Maciej Bis.
    Thread Starter patrickbolby

    (@patrickbolby)

    hi, thanks for the quick reply. Appriciete your help.

    “forside” is also a parent page. So thats why i also appears. Then i have parent pages underneath that as well. and i keep getting all the parent pages into the URL.

    I tried with both %pagename% and %pagename_flat%

    Still getting parents in the url.. why?
    https://snipboard.io/GyOgxL.jpg
    Do you think something has been hardcoded into my code-editor? Some developers have been working on my page.

    also you should maybe consider changing the URL here then. To the new page.

    https://snipboard.io/kXYA52.jpg

    Thread Starter patrickbolby

    (@patrickbolby)

    Thread Starter patrickbolby

    (@patrickbolby)

    Plugin Author Maciej Bis

    (@mbis)

    Thank you, the link is updated now.

    Please keep in mind that all modifications to Permastructures only affect new pages and do not affect old ones. You can force the new settings for existing pages using “Regenerate/reset” tool:

    https://permalinkmanager.pro/docs/basics/how-to-regenerate-the-custom-permalinks/

    After you regenerate the custom permalinks, the original URL:

    forside/sport-og-fritid/sportsur

    should be replaced with:

    sportsur
    Thread Starter patrickbolby

    (@patrickbolby)

    I think i was able to get help from GPT

    by giving me this code for function ´.php

    function pm_remove_parent_path( $default_uri, $native_slug, $post, $slug, $native_uri ) {
        $uri_parts = explode('/', $default_uri);
        $slug_only = array_pop($uri_parts);
    
        return $slug_only;
    }
    add_filter( 'permalink_manager_filter_default_post_uri', 'pm_remove_parent_path', 10, 5 );
    



    It worked in the first test i just did.


    You don’t just have a setting for this? Or is it just a bug on my end that it keeps adding parent pages.

    Thread Starter patrickbolby

    (@patrickbolby)

    “Please keep in mind that all modifications to Permastructures only affect new pages and do not affect old ones.”

    Yes, I know that. I’ve been testing this always by creating new pages with parent pages acossiated to it. Saved it. And so far all tests has failed to be without parent pages in the URL. But the code snippet above from GPT got rid of it.

    Still wondering; No settings for this ? Or just on my end it bugs?

    Plugin Author Maciej Bis

    (@mbis)

    I have checked the screenshot with your Permastructures again and forgot to mention that the tag you used %pagename_flat% is not supported. This is why it did not work.

    For pages, you can use either %postname_flat% or %page_flat%. Could you try to change the tag in Permastructure settings and see if it works without the extra code snippet?

    Thread Starter patrickbolby

    (@patrickbolby)

    but Pagename_flat was taken directly from your documentation i think?

    But ok i will try to change that, delete the code snippet, and let you know. Just a moment

    Plugin Author Maciej Bis

    (@mbis)

    Yes, indeed, sorry for the inconvenience.

    I will patch it in the plugins codebase so that the %pagename_flat% tag is supported out-of-the-box in the next release.

    Thread Starter patrickbolby

    (@patrickbolby)

    Well well. Actually both postname_flat and page_flat worked. (and yes i deleted the snippet from above in functions.php when testing this)

    Then documentation is quite misleading. You might as well update this too then

    https://snipboard.io/Em1igH.jpg

    Plugin Author Maciej Bis

    (@mbis)

    I adjusted the documentation and added the support for %pagename_flat% to the new dev version.

    The reason for all the confusion is that, although this version of tag was supported for many years, I must have deleted it at some point when I was optimizing and restructuring the plugin’s code.

    Once again I apologize for the inconvenience and thank you for your input.

    Thread Starter patrickbolby

    (@patrickbolby)

    I’m just thankful for your quick help even though im using lite version. Thanks. Hope my feedback helped you as well

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.