Skip Navigation

[Resolved] Confusion between Taxonomy OR Custom Field

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by AlimB3245 3 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1677507

Tell us what you are trying to do? I have a custom post type FRAGRANCES which has an attribute for which I could use either a Custom Field with SELECT or a Taxonomy with a checkbox or something.. I can't decide which one to choose.. could you advise what should one foresee when deciding between a custom field and taxonomy?.. Both would work for me, according to me.. I would prefer the custom field as in Taxonomy, there seems to be this option of the USER/EDITOR being able to add a newer one.. but I am not sure which one is really better.. does it affect the SEARCH/FILTER?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?hidden link

#1678375

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alim,

Thank you for getting in touch.

If you want you user's to be able to add new Options then you should go for the taxonomy because if you're setting up a frontend form for them to be able to create and they want to add a new option, they won't be able to with a custom field. They can with a taxonomy.

Also taxonomies generate custom archives so you can go to that respective term and see all the posts with that value selected.

For the frontend search, the only disadvantage I can see is that the taxonomy filters will always operate based on an OR principle. What this means is that if you are filtering for posts that has Term A and Term B selected then you will get posts with Term A selected only, Term B selected only and Both Term A and B selected.

You won't be able to get posts with Term A and B selected only.

Please let me know if this clears things up for you.

Thanks,
Shane

#1678613

Hi Shane

Thanks for the update..:-)..

Also taxonomies generate custom archives so you can go to that respective term and see all the posts with that value selected.
That seems like a good option.. but just to confirm, I could also create a view with a filter applied and have a page that would display all posts with that particular field selected (if I were to use custom fields).. right?

For the frontend search, the only disadvantage I can see is that the taxonomy filters will always operate based on an OR principle. What this means is that if you are filtering for posts that has Term A and Term B selected then you will get posts with Term A selected only, Term B selected only and Both Term A and B selected. You won't be able to get posts with Term A and B selected only.

I am a bit confused with the above statement.. so if Alim and Shane were 2 authors of a POST and if we had taxonomy (instead of custom field) as per your explanation
I could get all posts by SHANE only (you will get posts with Term A selected only)
I could get all posts by ALIM only (Term B selected only)
I could get all posts by ALIM and SHANE (Both Term A and B selected)
BUT
You won't be able to get posts with Term A and B selected only.
I didn't understand this above line.. what's exactly the difference between *Term A and B selected* and *Term A and B selected only*

Are you saying that I will not be able to select combined Posts of ALIM only and SHANE only?

I am assuming that's what you are saying but I'd appreciate if you could confirm so that I am sure I am in the right direction.

Also does this mean that with custom fields I could use the AND option and get the POSTS that belong to ALIM only & SHANE only while in taxonomy I can only get (posts by ALIM) OR (posts by SHANE) OR (posts by ALIM & SHANE) but I will not be able to get (posts by ALIM) AND (posts by SHANE)

Please do confirm.

Regards,
Alim

#1680601

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alim,

I did some checks on this to confirm my assumptions based on past tickets, however what happens is contradictory to my previous statement.

In both cases with Taxonomies and Custom fields. If you have Option 1 and Option 2 selected in the search you will get Posts with Option 1 selected, Option 2 selected and Both Option 1 and Option 2 selected.

Where there are cases of Different taxonomies or Different custom fields you can set an AND comparison between them.

Lets say I have a custom field or Taxonomy called Country and another called City.

If I have a filter for country and a filter for city and I selected Country A and City C. I will only get posts with Country A and City C selected.

Please let me know if this clarifies the issue for you.

Which brings me to where Taxonomies have an automatically generated Archive while custom fields don't and also to reiterate the point where users can Add missing taxonomy terms from the frontend forms when the term they want isn't there.

Thanks,
Shane

#1681441

Hi Shane

Thanks for the clarification and update..:-)..

Yes, it's a lot more clearer now.. I think I will use taxonomies only if
1) I need addition from the front end
2) If there's a common attributes to be applied to different custom posts (as taxonominies can be assigned to multiple post types while custom fields are unique to the one it is applied for)

I had another related query.. While taxonomies do allow for automatically generated Archives, I don't see a need for this as it allows for only the PARENT taxonomy and not CHILD taxonomy.. right?

If I had a custom post type called RETAILERS and a taxonomy COUNTRIES (which had 2 countries USA and JAPAN).. I could create an archive for COUNTRIES.. but that'd show me the same as an ARCHIVE for RETAILERS.. right?
I would want an archive for USA.. would that be possible?

If not an archive, then is a VIEW possible in this case? I was a bit confused as I know how to create a VIEW with a custom field.. add a Query and filter it out.. that's simple.. but does it allow you to filter based on a taxonomy? It seems like a simple enough requirement but I couldn't seem to manage to do this.. maybe I was doing something wrong.. or maybe I just need some sleep!..;-).. hehe..

Please do advise.

Regards,
Alim

#1682351

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alim,

2) If there's a common attributes to be applied to different custom posts (as taxonominies can be assigned to multiple post types while custom fields are unique to the one it is applied for)

Actually the custom fields can be assigned to multiple Post Types as well. You do have the option to re-use existing custom fields when you are creating a new field group for a different custom post type.

I had another related query.. While taxonomies do allow for automatically generated Archives, I don't see a need for this as it allows for only the PARENT taxonomy and not CHILD taxonomy.. right?

Each taxonomy term will have its own archive page. This archive is dynamically generated as wordpress treats the term archive templates the same regardless of if the term is a child or a parent so both will get a generated archive.

If I had a custom post type called RETAILERS and a taxonomy COUNTRIES (which had 2 countries USA and JAPAN).. I could create an archive for COUNTRIES.. but that'd show me the same as an ARCHIVE for RETAILERS.. right?

If you create the Archive for Countries and select only Countries for the archive selection then only the Countries taxonomy will have this archive. If you select Retailers as well then both Countries and Retailers will share the same archive template.

I would want an archive for USA.. would that be possible?
You won't be able to create an archive for a Single term as the archive is shared amongst all terms.

If not an archive, then is a VIEW possible in this case?

You can create a taxonomy view and then add a term filter to that view and select only USA but in order to display the child terms for USA you will need a nested view setup.

but does it allow you to filter based on a taxonomy? It seems like a simple enough requirement but I couldn't seem to manage to do this..

Yes you can filter based on a taxonomy. There is a term filter on the view that you can use.

Please let me know if this helps.
Thanks,
Shane

#1688717

My issue is resolved now.

Thanks Shane..:-)..

Have a nice day..:-)..

Regards,
Alim

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.