Allow the selection of a main term (i.e: category) for given post types

  1. pmdci

    Following the default taxonomies (categories and tags) and post types (posts and pages) that comes with WP, consider this scenario:

    Imagine that I use posts to list IT contractors, and I use Categories for the Cities they are available to work in.

    The idea would be that when editing the post and selecting the categories (cities), we could highlight the main category for this contractor.

    This way, when browsing the list of posts (contractors) in the index.php or whatever custom page, we could give emphasis to the main city where this contractor is based on. Once looking at his full profile (say, the single.php template) then the other cities (categories) could be listed as well, or perhaps differently.

    I can see workarounds with current WP features to obtain a similar functionality. For instance I could use custom fields in the post type for typing the main city. But what if Someone commits a typo, or writes the name of the city/location differently?

    I mentioned posts and categories here, but I really wish this could be extended to all taxonomies (custom and default). So we can have the option to select a main term for a given post type (also, either custom or default).

    Posted: 7 years ago #
  2. Mark


    So essentially, certain categories are more important than others. Then using a hierarchical structure suggests itself.

    For example, make all city cats subcategories of a meta-category 'city' or 'location'. With a simple check (along these lines) you can see what the city-child for a given post is, and give this category prominence in your theme. With sCategory permalink you can even control which cat appears in your permalink (which normally —stupidly!— depends on the category ID in the database).

    I don't really like that latter plugin though (it works with custom fields underlyingly and has to be reapplied for each post), so for one site I've gone the hard way and changed my category IDs to make sure the permalinks are showing the primary ones.

    Posted: 7 years ago #
  3. Mark


    (I'm giving the idea a low rating because I don't see the majority of WP users needing this. It's pluggable.

    Posted: 7 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    5 Votes
  • Status

    This is plugin territory