Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Custom Post types parent/child relationship

I am building a website for an art gallery using WordPress. For some of the content I am using Custom Post types.

I have 4, Artists, Exhibitions, Works Available and Artist News. I need the Artist Custom Post type to act as the parent and the other 3 to act as the child then on the front end I need to have a menu on the Artists page like this:

Jo Blo (Artist)

  • Artist News
  • Work Avaliable
  • Exhibitions

What I need to do but can't work out how is to set it up so I can choose an Artist as a parent for 1 of the 3 child custom post types.

I know that if I put 'attributes' in the line supports in the functions.php file when I register the custom post type as well as set hierarchical to true it as the parent box but it only allows me to chose another post from that type.

Is it possible to choose a parent for a custom post from another custom post type and if so how do I set that up?

Any help would be greatly appreciated.

Cheers

like image 938
Phil Avatar asked Oct 19 '13 13:10

Phil


2 Answers

Check out the Advanced Custom Fields WordPress plugin.

It has built-in support for:

  • Post Object linkage;
  • Relationships.

The plugin is open-source, popular and well maintained.

like image 146
Bart Verkoeijen Avatar answered Oct 19 '22 03:10

Bart Verkoeijen


@Phil,

There are 2 articles might be helpful for you:

  1. Select post parent from another post type in WordPress by me
  2. Post relationships: Parent-to-child by Justin Tadlock
like image 38
1fixdotio Avatar answered Oct 19 '22 03:10

1fixdotio