Home Forums Backend Issues (wp-admin) "Events" object – taxonomy or post?


"Events" object – taxonomy or post?

  • I need my site to include an Events object type and, in planning the data model, I’m agonising over whether this should be a Taxonomy or a Post. Can anyone help show me the light, or point me to the best source?

    This may seem like a generic question, but it has ACF implications, since the object would include ACF fields.

    Events would typically be conferences, and they would include a number of event-level, self-contained ACF fields.

    But there should also be a number of other fields/connections that link to other existing objects…

    • Organisation” (existing Taxonomy): Each event is staged by a company on the existing Organisation list.
    • Topic” (existing Taxonomy): Each event would be described by an existing Topic term, eg. “marketing”, “insurance”.
    • Posts: Some posts should relate to an Event.
    • User: One or more ACF sub-fields (Creator, Host, Moderator, Participants) should relate to an existing site User.

    I’m agonising because I’m thinking through the relative merits of Taxonomy versus Post, given some of the requirements, and coming up 50/50. Principally, around bidirectionality…

    • Organisation/Event: An Event object should be able to display the related Organisation term, but the given Organisation term should also be able to return any linked Events related to it.
    • Topic/Event: Same – An Event object should be able to show any linked Topics which describe it, but also any Topic term should be able to return any Events linked to it (eg. the “Marketing” term shows all marketing conferences).
    • Posts/Events: Posts need to be taggable with an Event, but Events should also return any linked Posts.
    • Users/Events: An Event should be able to show the Users linked to the given sub-field, but also every User should get to display any Events to which they are related.

    As a Taxonomy?:

    Registering Events as a Taxonomy would give me the opportunity to do something which I think I should do, which is nesting Event terms like this…

    If Events were a Taxonomy, their relationship with Posts would seem straightforward – standard tagging, which supports the two-way results.

    But I can’t wrap my head around relating Events (taxonomy) to Organisation and Topic (taxonomies). This would seem to call for a bidirectional Term-to-Term relationship… and how do I do that?

    Same/similar then goes for relating Events taxonomy terms to Users. I do run the LH User Taxonomies plugin (which supports taxonomies for Users) for some other things but, frankly, I have just discovered that it doesn’t like a Taxonomy being registered to both a Post and a User at the same time, and this may go for multiple-objects of any kind.

    Events as taxonomy terms feels like the natural way. I already have (and will have) several other terms in the generic “Tags” that actually are Events, and I could just switch their Taxonomy to Events. But I’m not certain… eg. these wouldn’t necessarily be searchable or throw off an RSS feed item, right? Is Event an organisational structure for content, or a piece of content?

    As Posts?:

    If Events were a Post, it seems like the relationships to Organisation and Topics ae straightforward, since both are Taxonomies; looks like standard two-way relationship.

    But, to support Event relationships to actual content Posts, seems like I would need a bidirectional Post-to-Post relationship. Am I right? I have seen some stuff online/this site about this, but have not yet tried. Doesn’t seem straightforward to me.

    Same curiosity goes for relating a Events Post type to Users. Could this be two-way, and how?

    Also curious about the nested URL structure as above, eg. I presume I could force the Events Post type to take “Page Attributes” and therefore make the pages hierarchical through having Parents.

    I guess Events as Posts would be searchable and give off RSS output.


    I’m hesitant to jump in one way or the other, for fear of making the wrong call and wasting development time. But that also means things are not progressing.

    What is my next step?

  • I would recommend creating a custom post type of Event and then adding your ACFs to that post type (set the rule up for the field group). Use the ACF Relationship field type to associate the Event custom post type to other posts (of any post type). There is really good documentation and code examples for this in the ACF docs. (and, it’s bidirectional!)

  • What, the (post) Relationship is bidirectional by default??

    I really didn’t glean that from Relationship docs.

    Ah-hah, it links to

    I have to try that!

    Where does this leave

    Are they ir/relevant?

    Thanks, @darusharp.

  • And is this native bidirectionality built-in if Events were to be a Taxonomy?

    Ie between

    * the Term and Posts? (add posts Relationship to Term field group, and add Term selector to Posts field group?)

    * the Term and Terms (add different Term selector for each Taxonomy to the opposite Taxonomy’s field group?)

    * the Term and Users (add Term selector to User profile field group, and add User selector field to the Term field group?)

    Is there then a two-way relationship between any of those things?

  • Err… I think I see something regarding the “Querying Relationship Fields” doc

    If you have to query using get_field() on one end but get_posts() on the other, I’m not sure that’s *real* bidirectionality.

    Per the doc…

    “Related Viewpoints”, set on an Article post:

    set 3 x ‘Viewpoint’ posts:

    loop through $related_viewpoints = get_field('related_viewpoints');

    “Related Articles”, set on a Viewpoint post:

    the Article on which I set the Viewpoint post is not seen on the Viewpoint edit:

    have to return it/them with get_posts():

    So, there doesn’t seem like real bidirectionality here. To truly link them, you’d have to manually add the equivalent linked posts on each side.

    Could this be because I used a different field name on each side? related_articles and related_viewpoints. I don’t think so.

    – It looks like the doc on Bidirectional Relationships would implement this.

    – And @hube2’s plugin is a variant of that.

  • Okay,

    – I see the guide on Bidirectional Relationships is a filter that does exactly that… when you relate a post on one side, the code updates to make the inverse link on the other.

    @hube2’s alternate code is a variant that does not have the above code’s requirement of using the same field name on each side.

    This clears up my Post-to-Post understanding.

    But it doesn’t quite get me to finally determining which route is best for my “Event” type… Post or Taxonomy?

  • My rule of thumb is that anything that can be a single object is a post. It’s not how I’m going to relate them that’s important but what they represent. A taxonomy is uses when multiple descriptors can be applied to an object.

    An event is the single top level object. It can have multiple topics, another post type. Topics can have categories, that’s a taxonomy. For something like you are talking about I would probably also create a “user” post type of some kind, maybe call it “speaker” that may or may not be related to actual site users and instead of relating events to speakers I would relate topics to speakers. I may or may not use my own plugin to create bidirectional relationships for these. The plugin is really meant for simple relationships and I’d have to evaluate it’s use or building something custom depending on how complex the relationships ended up being.

  • Hmmm…

    anything that can be a single object is a post. It’s not how I’m going to relate them that’s important but what they represent. A taxonomy is uses when multiple descriptors can be applied to an object.

    In my case, the primary case is that some existing Posts should relate to an Event. Eg. Conference reports from “CES 2018”, from “Cannes Lions 2019”. I guess multiple posts from a single given event could constitute the “multiple descriptos applied to an object”.

    But there will also be some cases where the thing that relates to an Event will not be Posts at all but, rather, some indication that I had a *function* at the event – eg. speaker/host/panelist. That’s something I’d like to express on the Event page but also collate eg. “all events I hosted”. Regardless, these don’t seem to be expressions that arise out of a relation to any Post content.

    So that seems like a bit of both Taxonomy use-case and Post use-case.

    I would probably also create a “user” post type of some kind, maybe call it “speaker” that may or may not be related to actual site users

    I know where you’re coming from.
    My forethought on this one is deliberate, even if it may complicate things.
    I actually already have a Taxonomy called “People” with a couple of thousand terms, which would be suitable. But, for the forseeable future, the only person I would want to relate to Event roles like host/panelist is… me… and I’m a User. In the future, I can theorise extending the same to other members/Users of the site. Those people would also have Post content and I would be one of the Users alongside them, so it seems natural to think about linking to a User.

    Stepping back to think aloud…
    Let me see…
    If “Events” were a Taxonomy, perhaps I could just not sweat the missing bidirectionality caused by the absence of a two-way Term-to-Term relationship. Thinking about the contexts in which information would be displayed, where things can be saved without needing to see it on both sides, and what’s really required…

    Event object / single term page:
    – Seve/relate the majority of fields here…
    – inc User event role (would not naturally/conceivably be set on the User profile anyway)
    – inc Organisation (could arguably want to set related events on the Organisation page as well as Event edit, but is it really essential?)
    – inc Topics (set the Topic on the Event edit, not the Event on the Topic edit).

    Post object / single post page:
    – Tag the post with the relevant Event, from Post Edit. I shouldn’t fret that I couldn’t do it the other way around.

    After all, in the case of native WordPress relationships, I shouldn’t justifiably expect to use a Term page to set and unset Posts, should I?

    So maybe I should just use Events as taxonomy, then relax about setting some related fields in the right contextual place and not expect to see the related pieces in their mutual backend locations?

    So, sometimes I would be displaying terms, sometimes Posts, depending on the context of the theme file.


Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘"Events" object – taxonomy or post?’ is closed to new replies.