Support » Plugins » Custom Posttype Parents with/without hierarchical permalink

  • So me and wordpress have had a few battles today. Google has taken a lot of searchqueries, but I’m somewhat underway.

    I have a Custom Posttype named Articles (because we dont want to mix them with pages, and blogposts are going to be used for a different area).
    To this posttype I want to be able to select a Page to be its parent. For this I have found a solution which is this:

    function remove_article_meta_box() {
    	remove_meta_box('pageparentdiv', 'article', 'normal');
    add_action('add_meta_boxes', 'add_new_artikel_meta_box');
    function add_new_article_meta_box() { add_meta_box('article-parent', 'Article', 'article_attributes_meta_box', 'article', 'side', 'high'); }
    function article_attributes_meta_box($post) {
    	$post_type_object = get_post_type_object($post->post_type);
    	if ( $post_type_object->hierarchical ) {
        $pages = wp_dropdown_pages(array('post_type' => 'page', 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0));
        if ( ! empty($pages) ) {
          echo $pages;

    But when I then add a parent to the article I get the following permalink
    /article/parent/parents-sub/article-title/ which is not what I want (and it doesn’t work either, only if I remove the parent-stuff it works). I rather be happy with this: /parent/parents-sub/article-title

    I have found different solutions, but everyone has the same ending. They all have the same parent (by setting the slug to it, if I dont remember wrong). I want to be able to use different parents for all sorts of things. Like:
    and so on..

    I guess I might be in over my head with this?

    Another solution for my problem would be to not get the parent-hierarchical in the permalink at all, but keep the hierarchical-“link”, because i DO want the breadcrumbs atleast. Say I use News -> Latest News for my Article parent but get the permalink as follow: /article/article-without-parents but still manage do read parents from the article to show breadcrumbs on the articles page.

    Any takers on this?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Posttype Parents with/without hierarchical permalink’ is closed to new replies.