Skip to main content
6 votes

Display entries by category (multiple categories)

You can use .relatedTo(category) {% for category in craft.categories.group('categoryName') %} <h2>{{category.title}}</h2> {% for entry in craft.entries.section('news').relatedTo(...
Marco Schuler's user avatar
4 votes

How do I display the Category Title?

It depends how you're fetching the category. But if you've defined the template when setting up the categories it would be called be within a var called 'category', which would be a category object. ...
Clive Portman's user avatar
4 votes
Accepted

Method for creating Category Group landing pages

2nd Revision: The category group field layout is for categories within that group. Categories groups do not have fields assigned to them, only to the categories within a group. 1st Revision: To get ...
Chattervast's user avatar
3 votes
Accepted

How do I display the Category Title?

This is the solution: {% set category = craft.categories.slug(craft.request.getParam('category')).first() %}
MGX's user avatar
  • 479
3 votes
Accepted

Only show entries related to category

Personally I would set the category select field outside of the matrix block but that's up to you. The problem you are running in to at the moment is you are not looping over the matrix field. {% ...
Justin Dekkers's user avatar
3 votes

Working with multiple categories

I figured it out! If anyone is stuck at the same place here’s my solution: {# category is 'ford' #} {% set entries = craft.entries.section('support').relatedTo(category).find() %} {% set ...
Robin Sandborg's user avatar
3 votes

Image entry in a category template

It looks like you are trying to access a news variable that probably doesn't exist. {% for entry in craft.entries.section('news').relatedTo(category) %} {# Your image field will be found on ...
Ben Parizek's user avatar
  • 13.4k
3 votes

Relating a Category Entry to a Categories Field Type

Turns out I was overthinking it, I was able to connect it with the following piece of code. {% set levelOne = category.topLevelConnection %} {% for subCat in craft.categories.group('levelTwo')....
conormcafee's user avatar
3 votes

How to target Sub-Category of Sub-Category

I'm not sure, but I think you might need to use level in your loop. {% set categories = craft.categories.group('groupHandle').level(3) %} {% for category in categories %} // etc {% endfor %} ...
Ryan's user avatar
  • 1,952
3 votes
Accepted

Setting the page title for a category page

We would need to know how you render your title. Otherwise it would just be <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta charset="utf-8" /> ...
Robin Schambach's user avatar
3 votes

In Craft 3, (how) can I disable a category on a per site basis?

I guess it is either a bug or the developers don't want us to do it via cp request. In my plugin (phpCode) I can activate and deactivate categories per site easily but the cp template is missing the ...
Robin Schambach's user avatar
3 votes
Accepted

cannot get relatedTo by slug only ID

It does not work because the function does not accept slugs. Not sure what to answer here. It only accepts objects of type Element and ids as identifier. You can see the magic here foreach ($...
Robin Schambach's user avatar
3 votes
Accepted

Including Entry Property in Object

You want something like this: {% set seo = craft.seo.custom( 'Welcome back, ' ~ category.title ~ ', Test Meta Description!' ) %} Or even more clear (to me anyway): {% set seo = craft.seo.custom(...
andrew.welch's user avatar
  • 11.6k
3 votes

Output values from all entries in a specific section EXCEPT those with a specific category id

You can get the entry IDs that have are related to the category and then exclude them from the all the entries. {% set entryIdsWithCategory = craft.entries.section('driverPositions').relatedTo('7192'...
Simon Kuran's user avatar
  • 3,015
3 votes

How to filter a categories query

Your current query queries for all categories in the category group "title", ordering them by their title. If you want to list three specific categories, you'll have to create a categories ...
Mats Mikkel Rummelhoff's user avatar
2 votes

Change markup depending on category of an entry

You're currently fetching an array of categories even if there's only one it, I think. You either need to loop through the array or try replacing this: {% set categories = craft.categories.relatedTo(...
Clive Portman's user avatar
2 votes

Display the next and previous category

Based on your example and description, it's a bit hard to tell whether you are dealing with a category template or an entry template, because in your description you say that the category handle is ...
Douglas McDonald's user avatar
2 votes

Using the same title

You can set the URL format to be anything you want really, just setup your templates and then setup some routes; then it's all going to work automatic for your client and they never have to worry ...
Christopher Healey's user avatar
2 votes

How do I output all field values from a Category on the current entry?

If you have a Categories field on your entry called myCategoryField, you can check if it has any Categories selected by going: {% if entry.myCategoryField | length %} There are categories ...
Brad Bell's user avatar
  • 67.5k
2 votes
Accepted

Could different entities have the same handle?

No, having a field and a category group (or a section and a user group etc) share handles isn't dangerous at all. Being specific and semantic with handles in general can be a huge boon for keeping ...
Mats Mikkel Rummelhoff's user avatar
2 votes
Accepted

Entries related to BOTH categories

You can limit to only products that have multiple related categories like so: {% set dressesCat = craft.categories...first() %} {% set blackCat = craft.categories...first() %} {% set products = ...
Brandon Kelly's user avatar
2 votes

loop through an entry's "related entries", grouped by category

Try this: {% for category in categories %} <h2>{{ category.title }}</h2>{# spit out the Category #} {% set entries = craft.entries.section('news').relatedTo(category) %} {% ...
Brad's user avatar
  • 487
2 votes
Accepted

Top level entry url not rendering category in url

I imagine it's because you're trying to access productCategory on category instead of the entry. When you're setting entry urls you don't need to use the entry prefix as it automatically expects this ...
Luke Pearce's user avatar
  • 3,863
2 votes

Element API access param in transformer

I managed to get access to the slug in the transformer function by using use. I'm not sure if it's the correct way but it works for now. 'api/series/<slug:{slug}>.json' => function($slug) { ...
samput's user avatar
  • 51
2 votes

List entries by category

This will exclude empty categories, meaning they don't have any entries associated with them. {% set entryIds = craft.entries.section('channelHandle').ids() %} {% set categories = craft.categories....
Ryan's user avatar
  • 1,952
2 votes
Accepted

Macro for entry loop causing 'null' variable template error

Your blogroll can be treated as a PHP function. In order to use functions you have to pass the required parameters. In your case your blogroll expects the parameter entry {{ blogroll.blogroll(entry) }...
Robin Schambach's user avatar
2 votes
Accepted

Set Up Route to Template - then variable Entry is undefined

Variables like entry are only auto-injected for routes that match the Section's Site Settings routes: If you're using custom routes, they won't match, and you'll need to set entry (or whatever) ...
andrew.welch's user avatar
  • 11.6k
2 votes

Categories or Structures: Most efficient way to organize FAQ sections

If your clients wants to have control about the order of the entries for each audience, e.g. Trainee Advertising Ad Entry 2 Ad Entry 3 Associate Advertising Ad Entry 3 Ad Entry ...
io_berlin's user avatar
2 votes

How can I display just the "lowest" categories assigned to an entry and not parent categories?

A bit late, but I've just come across this very problem and found a solution that works well enough. Thought I'd post it here in case anyone is trying to do something similar. As far as I can tell, ...
MoritzLost's user avatar
  • 11.3k
2 votes
Accepted

{{ category.title }} error with category groups

You should replace postCategories with whatever the handle of the category field is for your entry.
Oli's user avatar
  • 7,495

Only top scored, non community-wiki answers of a minimum length are eligible