Support » Fixing WordPress » How to set static page as parent of Custom Post Type page

  • Resolved petriedish


    I’m currently working on an animal rescue site (built with Headway v.3.5.5) that has animals available to sponsor on a monthly basis, as well as animals available to adopt.

    I’ve created 2 custom post types, one is animals-adopt and one is animals-sponsor, to showcase individual animals.

    I’ve already figured out how to list the animals available for adoption on my static Adoptions page, and list the animals available to sponsor on the static Sponsorship page.

    Here’s where I’m stuck. I want the static Adoptions and Sponsorship pages to be assigned as the parent pages for my respective custom post type single pages.

    Right now, when someone clicks through on one of the animals listed on the static page to open the single CPT page, the breadcrumb navigation on the CPT page shows the Home page as the parent page of the CPT and not one of the respective static pages I’ve mentioned.

    It shows: Home > Fluffy
    I want it to show: Home > Our Work > Adoptions > Fluffy

    I’ve tried to figure out a way to set a static page as a parent page for the custom post type in the page editor, but there is no metabox that allows for a static page to be a parent of a custom post type – it only allows another custom post type to be a parent of a CPT page.

    I’ve tried timstl and ipixelsmediaworks’s suggestions from this page (adding them to functions.php with the appropriate customizations) to no avail.

    I’ve spent almost a week researching to try to figure this out. Anything else I’ve found in forums is either unresolved or closed to new replies.

    Can anyone help me?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You could try using this custom breadcrumbs script vs the one in Headway. This shows a full breadcrumbs and not the abbreviated one.

    So I may have the answer, or I may be talking rubbish…
    I would make some changes. Give your CPT either a category /custom taxonomy and make sure it has a hierarchy.
    (Ill just use the word category for category/custom taxonomy to stop me having to type it so much!)
    So for Fluffy, he would be in the dog’s category. That would be a child of the category for all animals.
    So your hierarchy would look like so
    All Animals – dogs — fluffy
    So your breadcrumbs, rather than having to jump through hoops, would just be normal parent/child categories.
    You would need to either edit/make a new category archive page, that has the content from your static pages on it. This would also self update when you add new pets.
    Let me know if that either works or I didn’t explain it very well!

    I posted my same issue in the Headway forums and this is what someone posted that he’d found:

    Does anyone know where I add this code?


    add_action('admin_menu', function() { remove_meta_box('pageparentdiv', 'chapter', 'normal');});
      add_action('add_meta_boxes', function() { add_meta_box('chapter-parent', 'Part', 'chapter_attributes_meta_box', 'chapter', 'side', 'high');});
      function chapter_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' => 'part', '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;
          } // end empty pages check
        } // end hierarchical check.

    Or, I’ve just also seen the Posts 2 Posts plugin… does anyone know a step by step way I can use this plugin to achieve my goal?

    Or anyone have luck doing something like what I’m trying to do, using the Types plugin?

    I ended up using two plugins to as workarounds solve my issue and get the breadcrumbs and URLs I wanted.

    There was no way to “set” the parent of the CPT page as an existing static page (therefore no way to have the breadcrumbs and URL/permalinks automatically work.)

    So, I used the Breadcrumbs Nav XT for the breadcrumb issues, and I used the Types plugin for the URL issues.

    I recreated every static page in the site’s “Our Work” section instead as a CPT page, and used Breadcrumbs Nav XT on those pages only because I could modify the breadcrumb path to appear the way I wanted within that plugin’s settings for CPT pages.

    An explanation of how I used the Types plugin to get the permalink URLs I wanted is here.

    The Striking Premium WordPress Theme has both custom urls and custom breadcrumbs as part of its core settings for its custom portfolio post type. So I believe you can accomplish what you need with that theme.

    I had issues getting the permalinks to link to the actual custom post type (got a 404). My solution was a little bit of rewrite rules: (if anyone ran in to the same thing)

    add_filter('rewrite_rules_array', 'customposttype_rewrites');
    function customposttype_rewrites($rules){
    	$the_parent_page_permalink = substr(get_permalink(70), strlen(home_url('/')));
    	$rules[sprintf('%s(.+?)/(.+?)$', $the_parent_page_permalink)] = 'index.php?customposttype=$matches[2]';
    	return $rules;

    Apologies in advance if this question isn’t appearing in the right thread, but I can’t figure out how to start a new post.

    I’ve been learning web design and have created a page, which is an html file, 2 css files, and a .js file. Can I add it to my wordpress blog? I don’t want it to have the structure of the blog. How would I do that?

    Or do I really need to purchase another domain name just for these little files and just have an external link to it on my blog?

    I hope this makes sense. Can anyone give me any advice?

    Thanks! Mary

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to set static page as parent of Custom Post Type page’ is closed to new replies.