Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [categories]

Categories are taxonomies for your entries, users, and assets.

Filter by
Sorted by
Tagged with
17
votes
1answer
6k views

How do you list categories in a category group?

I would like to output a list of all the categories in a category group on the front end. How do I do that?
13
votes
1answer
6k views

Get category title by slug

I'm setting my categories by matching the third segment to a category slug. How do I get the category title? {% set catSlug = craft.request.getSegment(3) %} {% set category = craft.categories.slug(...
13
votes
2answers
1k views

Difference between categories and structures

The recent updates to categories have been great and provide a lot of flexibility. But now I find myself struggling to decide what should be a category group and what should be a structure. For ...
12
votes
2answers
1k views

How to find entries with no category

I have a field categories in a channel news, and I want to find all the entries in news that don't have a category set. I know I could loop over the entries and find them that way, but I'm hoping to ...
11
votes
2answers
3k views

How to filter entries by clicking multiple categories on front end

I would like to be able to filter my entries list by multiple categories on the front end. For example, if I first click a category button "lunge" then the results would show entries which are ...
11
votes
2answers
3k views

Advanced Search

Not sure of the best way to progress with this but i'm trying to create an advanced search on a Craft site. What it needs is a select dropdown for Authors, Categories and a normal text input. The ...
10
votes
2answers
9k views

Display entries that belong to a category

I have a page that should show entries within a category, and then entries within children of that category. Basically, I need a way to loop through entries that have a level 1 category but not a ...
10
votes
1answer
1k views

Check to see if category is populated?

I want to list all categories that have an entry assigned to them, but hide the ones that are empty. In EE I could do this show_empty="no" But I can't see a parameter in the docs for Craft. ...
9
votes
1answer
3k views

How to list entries related to a category + related to a section?

Sorry if this has been asked before. I've searched for other relatedTo questions but could not find anything similar. I have 2 sections (each having 1 entry type): games reviews Games are linked ...
8
votes
1answer
4k views

Users relatedTo multiple categories

Trying to get users in a members group related to multiple categories. {% set services = craft.categories.group('services').slug('service-1, service-2') %} {% set locations = craft.categories.group('...
8
votes
1answer
2k views

How do I add a subcategory to the URL slug for a channel entry?

I'm trying to mimic the URL structure exactly how I have it in my old CMS. If I select an entry to have both a category and subcategory I would like to have the subcategory in the URL along with the ...
8
votes
2answers
465 views

Is there any way of specifying a default category for a category field?

I've set up a channel using categories to distinguish between different blog post types. The majority will probably be in one category, so it would be great to be able to specify a default category. ...
8
votes
1answer
1k views

Building a simple search by multiple categories

Is it possible to build the following/is it the right way in Craft. Been through the docs and searched but stuck. I just need to build a form on one page with a dropdown select for 2 categories; ...
7
votes
2answers
1k views

Listing categories with post count in a nav?

I'm trying to list my categories (and sub categories, just one sub level) as a nav, and have the number of entries in each of those categories beside each one. There is another question on here which ...
7
votes
1answer
801 views

How to get entries related to current category only (not children)

I need to get entries which are only in current category, not child categories. So if I have a category structured like this: Food ----Fruit -------Apples -------Bananas I've got a categories ...
7
votes
1answer
708 views

Filtering/searching for entries by category in the control panel

Is there any way of filtering by category in the control panel entries list? Likewise, is there for an "entries" field (like how Playa lets you filter by channel, category)?
6
votes
2answers
2k views

How can I create a simple loop through entries in a category?

I have a category set up and have added entries to it. How do I loop through these entries, and output just the title of each entry? Serious noob here but trying to learn, any help would be ...
6
votes
1answer
603 views

Custom Category order in a Categories Field

I have a load of projects, each of which can have zero or more categories which indicate the particular type(s) of work involved. As well as using these categories to produce a 'category page' of ...
6
votes
2answers
2k views

Showing just the child category titles of a parent

I have a category group with parents each with 1 level of children. On my category entry page I want to list JUST the children of the current category being viewed. I'm sure it's simple but I can't ...
6
votes
1answer
911 views

How can I get to a category via the category slug using the ElementAPI

I am using the ElementAPI to generate a json response of data based on the value (locations) that was chosen from a drop-down. I think I have all of the pieces I need, i'm struggling with how to put ...
6
votes
1answer
213 views

Reorder selection of categories in category fieldtype

I'm looking to reorder my selected categories within a category field. I'm hoping this is possible because the order an editor selects these categories is important, primarily for the .first() ...
5
votes
2answers
2k views

Order entries by category field

I'm loading a set of entries related to 'category' and ordering them by the value of a Dropdown field in the entries. This work well using this code: {% set entries = craft.entries.relatedTo(category)...
5
votes
3answers
1k views

How can I display the related posts (by category) at the bottom of each post?

I'm converting a WordPress blog to Craft - first time playing with categories in Craft, so how can I display the related posts (by category) at the bottom of each post?
5
votes
1answer
158 views

What is the difference between 'nav' and 'for' for looping?

I am new to craftcms and did a look through on the documentation just recently. I am at the part where it explain about the Categories Field and found out that we can loop through the ...
5
votes
2answers
902 views

Get the Category name into the URL for an entry

I have a gallery which is categorised. The gallery is a Structure section where the user adds an entry and then assigns it to a category - all good. At the moment, when clicking on an entry title the ...
5
votes
2answers
583 views

Categories field is losing its value when programmatically updating other fields’ values

I have a webhook that fetches an entry, modifies one of its custom Text field values and then saves the entry. However there is also a required Categories field on the entry, and when I do this, I get ...
5
votes
1answer
849 views

Display category entries based on Segment?

I'm really struggling to display entries of a category, based on the segment. In other words, I have 1 category template, so the category needs to be determined dynamically (*we still do this by ...
4
votes
1answer
2k views

Showing categories in Channel Entry URLs

I have a site which has two blog-like sections, which I'll call Blog and News. Each has a few categories. The categories are different in each section. An article always has (only) 1 category assigned ...
4
votes
1answer
2k views

Listing categories alphabetically & total post count

How do I list all categories in use alphabetically? And how to get the total post count from each category? Cheers
4
votes
3answers
812 views

Get entries by category value from within plugin

I need help. I want to get entries based on multiple field search. It works for basic field types like selectbox or plain text but I can't get it to work with Categories Fields. The field size is a ...
4
votes
2answers
1k views

Best way to programmatically create categories?

We're working on an XML import plugin to migrate content from another CMS. What's the best way to create a new category (with a name, slug etc.) and assign it to the entry when running $entryModel = ...
4
votes
1answer
2k views

How to loop through category group and identify those related to entry

Looping through a category group to show links to all the categories. This is an entry page and I want to highlight any categories assigned to the entry. How do I do that? I've tried this so far: {% ...
4
votes
1answer
349 views

Filtering multiple categories with URL queries

I am trying to filter using categories. I have to filters type and size, in the url. /products.html?size=medium,large&type=polo-shirt,jeans In my template, I am doing the following {% set sizes ...
4
votes
1answer
930 views

Ordering of products?

What is the best method to organise products, and subsequently the order of these products within a group? Currently I have setup a product type of Canine. I can access each of these products via a ...
4
votes
1answer
745 views

Saving Entry with Category field

I am stuck on saving entry with a category field. The error message I get is about not being able to create/update the entry in the relations table. $accomodationTypecategory = ['title'=>'Hotel'] ...
4
votes
1answer
1k views

Product Categories, Structures and Channels

We are currently updating a brochure website, separating a single list of products into a series of sub-categories. Currently, we have a "single" section to display all products, and then a "channel" ...
4
votes
1answer
496 views

How can i apply “current” class for category nav?

I've browsed the questions and answers here and i can't find anything that works for what i'm trying to do! I am using this as the main menu of my site (so it is in _layout.html) {% nav category in ...
4
votes
1answer
587 views

How can I output a list of categories that are not empty?

In other words, categories must have at least one enabled entry assigned to them.
4
votes
1answer
252 views

Getting entries related to all of supplied categories, if they exist

I'm trying to get all entries that related to one .. three categories, as determined whether their id appears in the query string: {% set sector = craft.categories.id(craft.request.getQuery('sector'))...
4
votes
2answers
770 views

Is it possible to limit users to adding/editing entries in specific categories?

I'm building a site that regroups several properties, and I'd like each manager to edit content in his property only. All properties use the same templates and share content between each other. I ...
4
votes
1answer
925 views

Sections, Categories, and EntryTypes. Which, when?

bit of a 'best practice' question, as I'm very sure there are many ways to do this sort of thing, but... When/how do you decide whether to use a section, category, or entry type to organise your ...
4
votes
1answer
532 views

Craft 3 Multi Category and Field Search

Looking for the solution to searching entries in one section that are related to multiple categories and match number field criteria. This is for a used auto website. Categories: Make/Model/Trim: ...
4
votes
1answer
1k views

How to display the title of a category based on its ID?

I’m passing the ID of a category to a template via a catId query string (i.e. http://example.com/some/path?catId=10). How do I display the title of that category?
4
votes
1answer
68 views

What is the intended use of categories?

Just figuring out the craft interface and finding all sorts of useful features. Just can't figure out what the purpose of "categories" is in the settings. Would be much appreciated if anyone could ...
4
votes
2answers
566 views

Structure(s) vs. Categories for product catalog

So I am working on a project that includes an online product catalog. Is there a recommended way of setting up a catalog regarding the use of structure(s) vs. categories or a combination both? I ...
4
votes
2answers
668 views

How to query with relatedTo of a Relationship Field in a Matrix Field block

I have structures called Instrument and Person. On the person structure, I have a Matrix field called Roles. Roles has a block called Musician. And That block type has a Relationship Field called ...
4
votes
1answer
90 views

Sort entries by best match to multiple categories

I've got a channel where entries will be tagged with multiple categories. I want to use those categories to show related content for each entry. So if an entry has cat_a, cat_b and cat_c, I want to ...
4
votes
1answer
332 views

Simple search using a single category in Craft CMS

I am relatively new to Craft and I am having a little trouble understanding how to build a simple search which will allow me to have dropdown of my categories which will return the selected category ...
4
votes
1answer
899 views

Related to entries in categories in a plugin

Ok I can do this in twig but after searching high and low I can't find a good example of how to do it in a plugin. I have a user profile field called interests which holds an array of what they are ...
4
votes
1answer
457 views

Assign Category via Guest Entry Form

Is is possible to assign a category via a frontend Guest Entry form. I tried <input type="hidden" name="fieldHandle" value="SomeExistingCategorySlug"> But that did not work.