WordPress.org

Ready to get started?Download WordPress

Forums

Setting a Parent Page for a Custom Post Type (6 posts)

  1. devoninternational
    Member
    Posted 2 years ago #

    Is there a way to set a static parent page for a custom post type single page?

    In other words... I have a custom post type called "Press Releases" and I would like to say that its parent is "News," which is a static page.

    Maybe there is some way to utilize the "$post->post_parent;" code to name the parent for an item such as a custom post type. I know this is crude and will not work but some form of manipulation like this... "pressreleases->post_parent = news;"

    Thank you.

  2. govpatel
    Member
    Posted 2 years ago #

    You mean you want a page similar to blog page for your custom post type Press Releases and when you post anything it goes on the News page.

  3. devoninternational
    Member
    Posted 2 years ago #

    Yes, I believe that is pretty accurate. I currently have a custom loop on my "News" page template that achieves that, but the child pages (single) do not register as children of "News".

    [Code moderated as per the Forum Rules. Please use the pastebin]

    My main motive was to utilize this code to work with breadcrumbs and in the sidebars.

    Basically, how can I get my custom post type single page (press releases) to register as child pages of "news"?

    I figured by using a variation of the $post->post_parent code that I can trick the breadcrumbs into thinking the parent for the "press releases" is "news".

  4. govpatel
    Member
    Posted 2 years ago #

    You can create a template for your custom post type using index.php code and then make the change in template to query your custom post type

    I have a article on my website on how to use custom post type see this helps

  5. devoninternational
    Member
    Posted 2 years ago #

    I do not believe that is what I am looking for. I am able to pull in the custom post types but I can not register the single pages as having a different parent.

  6. MACscr
    Member
    Posted 2 years ago #

    Did you figure this out? I am trying to achieve the same thing with no luck. i think im just going to have to forgo custom post types for now. =/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.