• Hi,

    I’ve been set the task of developing a section of a website that displays artists, each artist has many pieces of artwork which need to be displayed as a gallery type page. When an artwork thumbnail has been clicked it sends the user off to that artwork post displaying all the details, image, content, and a few other properties.

    My thinking is I could create each artist as a page and have a custom post type called artwork, however how would I relate each artwork post to an artist?

    Thanks

    • This topic was modified 8 years, 3 months ago by hotdiggitydog.
Viewing 2 replies - 1 through 2 (of 2 total)
  • I’d do it the way that you’re thinking of, so that’s most likely the right way of thinking.

    As for the relation between the two, there’s a few ways of doing it, but there main two that I use are:

    1 – Direct one-to-one relation Best if the artworks will only ever have a single artist associated with them. The way that I do it, which isn’t stirctly the WordPress way, is to set the post_parent of the artwork to the ID of the artist.

    2 – One-to-many – To do this I’d add a new table into the database with the articst ID and the artwork ID as columns. That way you can add in any combinations that are needed, so an artist can work on multiple artworks, and an artwork can be related to multiple artists.

    As a note, both of these methods use custom work. There’s probably some plugins out there that could help, but I’ve just done it mysel fin the pst.

    anonymized-15380454

    (@anonymized-15380454)

    How about:
    1. Create a custom post type “artwork”.
    2. Create a custom taxonomy “artwork_artist” and attach/assign the “artwork” posts to this custom taxonomy.

    Example structure:

    Leonardo da Vinci (a term/category in the "artwork_artist" taxonomy)
      Mona Lisa ("artwork" post)
      The Last Supper ("artwork" post)
    Pablo Picasso (a term/category in the "artwork_artist" taxonomy)
      Asleep ("artwork" post)
      Bathers ("artwork" post)

    For each artist, create a standard Page, and use a plugin (or write your own custom functions) to display the corresponding “artwork” posts. For example, if the Page is for “Pablo Picasso”, then display only posts in the “Pablo Picasso” term/category (refer to the above example structure).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Pages and Custom post type relationships’ is closed to new replies.