WP 4.4 Permalink on private child pages (save_post)
-
Earlier, I had this problem that I had a private page, which had to have some child pages, which wordpress dont allow by default. So I added the following code to my functions.php to make private pages available as a parent page:
function admin_private_parent_metabox($output) { global $post; $args = array( 'post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column' => 'menu_order, post_title', 'echo' => 0, 'post_status' => array('publish', 'private'), ); $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'id' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '', ); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); $pages = get_pages($r); $name = esc_attr($name); // Back-compat with old system where both id and name were based on $name argument if (empty($id)) { $id = $name; } if (!empty($pages)) { $output = "<select name=\"$name\" id=\"$id\">\n"; if ($show_option_no_change) { $output .= "\t<option value=\"-1\">$show_option_no_change</option>"; } if ($show_option_none) { $output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">$show_option_none</option>\n"; } $output .= walk_page_dropdown_tree($pages, $depth, $r); $output .= "</select>\n"; } return $output; } add_filter('wp_dropdown_pages', 'admin_private_parent_metabox');
This worked swell.
However after updating to WP 4.4 and flushing the rewrite rules, it does not work anymore.
And this seems to be because the child pages now get the wrong permalink.
In example:Second page is a child page of first page.
Its permalink should bemydomain.com/first-page/second-page
However, now its:
mydomain.com/second-page
This ofcourse results in a 404 not found.
If I manually type in the correct permalink in the browser, it finds the page.Does anyone know what is changed, and if I can hook into a filter to overwrite this?
Thans.
- The topic ‘WP 4.4 Permalink on private child pages (save_post)’ is closed to new replies.