Support » Fixing WordPress » Page permalinks without hierarchy (parents)

  • Hi,
    I’d like to have permalink structure for Pages instead of default…

    I understand it will be probably necessary to modify some core files.

    I already did one step: WP correctly outputs this permalink structure for pages.

    Problem is the second step – rewriting (?), making the WP understand which page should it serve.

    Much thanks for any advice (token PP donation possible), unfortunatelly, I’m obviously not able to fully understand the process of URL analysis and query building to do it by myself.

Viewing 10 replies - 1 through 10 (of 10 total)
  • studiocodes


    I have figured out how to do this, just that not yet sure how to include the modifications as a plug-in to make the solution friendly to future WordPress upgrades. Still working on that part…

    Studiocodes… could you give some direction on to how you did it… Because I could really need to do the same…

    Where do you want me to send the fix to, brianbrandt?

    i’d also be interested in this, if possible. thanks!

    Hey there are more guys out here searching for it. I’m interested too.

    studiocodes, can you post your fix for this online?
    Or send it to me through my site –


    @studiocodes, Have you made any progress with the plugin?

    or if any one has the fix could you post it.


    Is a plugin neccessary? why not post some code?

    can you please post the code.


    Hi guys, sorry to have missed this thread for so long.

    If you’re still looking for the code to remove parent slugs from the page permalinks, here you go:
    OPEN: /wp-includes/page.php

    while ($curpage->post_parent != 0) {
    $curpage = $wpdb->get_row( $wpdb->prepare( “SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type=’page'”, $curpage->post_parent ));
    $path = ‘/’ . $curpage->post_name . $path;


    // A page cannot be it’s own parent.
    if ( $page->post_parent == $page->ID )
    return $uri;

    while ($page->post_parent != 0) {
    $page = get_page($page->post_parent);
    $uri = $page->post_name . “/” . $uri;

    Do not forget to save the file and make sure it’s updated on the test server. Once you did that, go to the Permalinks manager inside wp-admin panel and hit “Save Changes” once to update the permalink settings.

    Note: use these instructions at your own risk.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Page permalinks without hierarchy (parents)’ is closed to new replies.