When adding a listing, is it possible to limit to just 1 category?


When adding a new listing, you need to select a category. The selection for category is a 'check box', and I have created several categories.

So, Is it possible to only allow 1 category per listing? How?


  • Patrick

    Hi @Mitchell

    Welcome to the forums!

    You can't change how the listing categories work (ie - can't change from checkbox to radio button). But you could replace them with a custom field, then hide the built-in category selection on the front-end.

    In CustomPress, go to Content Types > Custom Fields and create a new custom field as seen in the 1st screenshot below. Set it to use radio buttons and add your "categories" as options.

    Then add a bit of custom CSS to your theme/child-theme style-sheet to hide the default category form on the front-end:
    #taxonomy-listing_category { display:none; }

    The result can be seen in the 2nd screenshot below.

    You would likely want to tweak the single-listing template to edit the "This entry was posted in" part of the meta, but we can get to that afterwards.

    Would this setup work for you?

  • Mitchell

    Hello @Patrick; Thanks for the quick response.

    I did try to create a 'custom field' for the 'category' and set it to 'radio buttons' as suggested but I don't like the output or the display of the 'radio buttons'. So I decided to use a 'drop down select box' (with category options listed). And I'm also able to 'hide' the default list of categories. It's all perfect now!

    So my follow questions:

    1. I'm using a short code to display 'all the categories and sub-categories' on a page, But because of the changes, how can I display my 'custom field - category'?

    2. With the 'custom field category', Is it possible to create or add a sub-category?


  • Patrick

    Hi again @Mitchell

    Whoops, it appears this topic fell off my radar. Terribly sorry about that.

    1. You can use the shortcode that is automatically generated for each custom field you create. To get the shortcode, click the "Embed Code" link under your custom field name (2st screenshot).

    Then add the shortcode to a page or widget, and your custom field value will display (2nd screenshot).

    2. Unfortunately, no. Custom fields cannot be nested like categories can I'm afraid.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.