• I am having an issue with the “Current States” and “Parent Pages” on a custom post type.

    Here is my setup:

    I have created a custom post type (Called Radiologist). Hierarchical is set to “true”. Capability Type is “post”.

    In the “Reading Settings”, my “Front Page” is set to be a static page called “Home”. My “Posts” (the blog) page is set to show on a static page called “News”.

    I have a third static Page called “Physicians”. When a visitor clicks on “Physicians”, they will see a list of all the radiologists (the radiologists being all the pages created with the new Custom Post Type).

    When a visitor clicks on a Radiologist’s name, they go that Custom Post Type.

    Here is the issue: WordPress seems to think that The Radiologist’s Parent Page is “News” (the blog page), when I want it to be “Physicians”. So the navigation is not showing “current_page_parent” on the wrong
    <li>.

Viewing 15 replies - 1 through 15 (of 29 total)
  • I’m having the same issue. In my scenario, I have a “Speakers” page (just a regular “Page” post type) using a custom template that lists out all items of my custom “Speaker” post type. Clicking on a “Speaker” in this list brings you to that individual “Speaker” post. This is all working, however, my custom post type “Speaker” seems to automatically be made a child of my blog page (in this case, entitled “News”) instead of my “Speakers” page.

    Is there a way to force a specific page to be the “parent” of a specific post type?

    pikemurdy, one possible work-around for you could be to manually add those Radiologists as children of your Physicians page in a custom menu in the Appearance > Menus screen. Doing this does seem to properly mark the parent of the post type based on its position in the custom navigation. This isn’t ideal, however, because, at least in my case, I don’t want to have to manually add each “Speaker” to a custom navigation.

    @pasiphilo I did that but it added one more page_parent to the blog and on to my custom post. Weird

    I have the same issue !!
    Nobody has a solution?

    My Scenario:
    I have “product” as custom_post_type,
    a Page called “products” that use a custom template.
    When i go to the single-product page my menu add a css class “current_page_parent” to the blog page but i would have the same class only on “products page” list element.

    I have the same issue and I’m pulling my hair out!

    Can anybody help?

    Me Too, same problem… Help! Anybody?

    I too have the same problem and couldn’t find anything to help.

    As a dirty, temporary solution (hope someone finds one!) I’ve used javascript and jQuery to change the selected menu item, hope it helps 😉

    <!-- Dirty hack to change current menu item (current_page_parent) -->
    <script type="text/javascript" language="javascript">
    $(document).ready( function (){
    
    	// change this with the menu ID which SHOULDN'T be selected.
    	var temp = $('#menu-item-34').attr('class');
    
    	// removes 'current_page_parent' class from current selected menu item.
    	temp = temp.replace("current_page_parent ", "");
    	$('#menu-item-34').attr('class', temp);
    
    	// change this with the menu ID which SHOULD be selected.
    	temp = $('#menu-item-43').attr('class');
    
    	// adds 'current_page_parent' class to desired menu item.
    	temp = "current_page_parent " + temp;
    	$('#menu-item-43').attr('class',temp);
    
    });
    </script>

    ive run into the same issue, really is odd… doesnt this defeat the purpose entirely of touting it as a “cms like” capability?

    I started by creating a custom post type called “Team”…and a regular page called “our team” wich acts as an index page… just a page template pulling in the custom “Team” pages.

    in my case my custom post type is set to “page”… i set the ‘supports’ argument when registering the custom post type to include ‘page-attributes’ thinking this would let me bring in the default parent drop down… wich would open up the existing ‘pages’ to set one of them as the parent.

    With the idea being that i could select the static “our team” page to be the parent. thereby integrating it all menu-wise.

    but even though the page attributes box does appear in the custom write panel, the ‘Parent’ drop down menu only shows pages of this particular custom type (team pages) wich is unfortunate, and doesnt make sense to me as these pages are essentially siblings.

    i had assumed this is what would have let us set ANY existing page as ‘parent’… as it is, there doesnt seem to be a way to have a proper “top level” page for custom pages.

    (on another note, the page template dropdown is missing entirely as well, wich was another surprise. it seems that the despite the term ‘capability_type’ A custom “page” type cannot use page template?

    these custom post types dont quite actually do what posts/pages are capable of.

    *******************

    I was thinking of creating an “our team” top level page as a custom post type and setting it as the parent of the other team pages (since now it would appear as an option) and then running a conditional statement in the custom single post template… and adding in the appropriate code that way (single post code if its a child, get all posts code if its a parent)

    But that would cause the same issue cippo mentioned above… double “parent” labels in the url. it could probably still work out with creative labeling, but it still means custom post types would always be 3 levels deep.

    ….good god i rambled

    same problem here!

    trying to create a single-custom-post-type-name.php but the menu item with current_page_item class is the Blog page item instead of the custom page with “Custom Post Type Name” Template!

    Having huge problems creating child themes with Thematic and Custom Post Type… it makes me want to work with pages instead of custom post types

    This annoying me as well. It basically renders the whole current_parent_item class naming pointless, since if you use posts the only parent you ever have is blog.

    The only was I can think of to get around it is creating a series of child pages and custom page templates like so:

    Parent:Work Page: Shows all custom type work posts.
    child:Single work page: Shows single work post.
    child:Single work cat page: If you have some categories for work posts.
    chuld:Single work archive page: Archive of work posts.

    I think, in theory, the current_page_item WOULD be ‘Work page’ for all the child pages, even though they are showings posts. The annoying this about this is that you have to make loads of pages and different templates. I’ll test it out and let you know if it works.

    No wait, that wouldn’t work because when you view a single post it always uses single.php or a variation of it. No way of displaying single posts through a page template as far as I’m aware.

    There must be some way of hacking this.

    i am having a similar problem with my CPT aswell,
    but my issue is that how do i separate the normal blog posts and CPT
    i have hunted the net for solutions but can not find any

    different issue entirely. I will PM you some info.

    i am having a similar problem with my CPT aswell,
    but my issue is that how do i separate the normal blog posts and CPT
    i have hunted the net for solutions but can not find any

    hi syrus69, to show only your custom posts create a page (i.e. page-artwork.php my case) and set your own WP_Query – have a code like this on the page:

    <?php
    $type = 'sf1_artist';
    $args=array(
      'post_type' => $type,
      'post_status' => 'publish',
      'paged' => $paged,
      'posts_per_page' => 4,
      'caller_get_posts'=> 1
    );
    $temp = $wp_query;  // assign orginal query to temp variable for later use
    $wp_query = null;
    $wp_query = new WP_Query($args); 
    
    get_template_part( 'loop', 'artists' );
    ?>

    for more info check these:
    http://codex.wordpress.org/Function_Reference/WP_Query
    http://codex.wordpress.org/The_Loop

    cheers mate will look into it

    I think this is a fairly generic and common requirement that CPT has really highlighted. The concept of post-type-hierarchy would solve most of these problems.

    In the classic ‘music collection’ example, you would have a CPT of ‘Album’ that had child CPT of ‘Track’. Adding new ‘Track’ posts would require the assignation of a parent ‘Album’ post.

Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘Custom Post Type Parent’ is closed to new replies.