Hot answers tagged

14 votes

How can I create a visually weighted tag cloud?

Marion Newlevant had a clever, efficient idea in this Straight Up Craft Hangout if you don't mind having a slight lag (like a day) for your tag counts to be up to date. That idea: store the counts you ...
Matt Stein's user avatar
  • 3,996
14 votes

Removing whitespace from {{ tag.name }}

Craft has a filter for "Kebab Case", which I think is what you need. It strips out punctuation and replaces spaces with dashes. Useful if you need to format a field as a HTML attribute. {{ tag.name|...
kmgdev's user avatar
  • 1,169
6 votes

Deleting unused tags

There currently isn't any Tag management in Craft, but if you think there should be, consider voting for this feature request. In the meantime, there is a 3rd party plugin called Tag Manager that ...
Brad Bell's user avatar
  • 67.2k
6 votes
Accepted

How do I add a value to a tag field type using the entries service saveEntry method?

The Tags field classifiedTags needs an array of tag IDs, not slugs/titles. Also, if this is an existing entry and you want to retain tags already added to the field, you'll need to pull the existing ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Query Entries by Tag

You'd need to get the tag model first. {% set tag = craft.tags.search('My Tag').first() %} {% if tag %} {% set entries = craft.entries.relatedTo(tag) %} {% endif %} Replace search with whatever ...
carlcs's user avatar
  • 36.2k
5 votes
Accepted

.relatedTo() not returning tags with spaces

In your working example, you’re mapping request.tags to the search param, but in the non-working example, you’re mapping it to the slug param. Those two params are handled in very different ways. ...
Brandon Kelly's user avatar
5 votes

How do I UNLOCK my account?

If you don’t have access to another admin account, you could unlock the account directly in the database. Change the lock value to 0 for the account in the craft_users table.
carlcs's user avatar
  • 36.2k
5 votes
Accepted

Confused about tags

You told Craft to look for tags/_tag And then you created templates/tags/_tags.html Note you have no s on the end in the route definition, but you do in the template name.
Jeremy Daalder's user avatar
5 votes
Accepted

SEO titles/descriptions for tags and archive pages

The better approach in my opinion is to declare the variables in the corresponding templates rather than in the _layout template Layout.twig {% if seoTitle is not defined or seoTitle is empty %} ...
Robin Schambach's user avatar
5 votes

Still not able to manage tags in Craft 3?

Short answer is "no, this still isn't possible". Longer answer is: The Tag Manager plugin from Craft 2 will not be ported. Pixel & Tonic have mentioned the possibility of rolling that ...
Lindsey D's user avatar
  • 23.9k
5 votes

How to delete tags in Craft CMS 3

Yes the same still applies. You can either delete it via DB directly in your {{%elements}} column or you can just run PHP Craft::$app->getElements()->deleteElementById(x) Twig {% do craft....
Robin Schambach's user avatar
5 votes
Accepted

How to delete tags in Craft CMS 3

I do believe this plugin can help? https://github.com/ethercreative/tags
Jay's user avatar
  • 1,042
4 votes

Listing All tags - and linking them to list of entries with that tag

You don't have a setting in Craft to make Tags have their own pages automatically. So what you have to do instead, is to set up a dynamic route in Settings → Routes. Create a new route which routes ...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

How do I display tags comma separated with "and" between the last two tags?

Bit of an old question, but here's a (subjectively) more elegant solution than the accepted answer using loop.revindex0: {% for tag in tags %} {{ tag.type }}{{ loop.revindex0 == 1 ? ' and' : loop....
Andy's user avatar
  • 156
4 votes

Plugin: Tags field for front-end Entry Form

While the full answer to this probably requires some planning, and a plugin that handles various aspects of the tag management, here are a few components to consider: You can submit tags from the ...
Ben Parizek's user avatar
  • 13.4k
4 votes
Accepted

Show all tags related to a category?

You can use the relatedTo param on craft.tags like you can with any Element inside Craft. All Elements inside Craft can be related to one another. There is a .relatedTo parameter available on all of ...
Luke Pearce's user avatar
  • 3,863
4 votes

List entries for a single tag from blog section

You were very close! You are looping through craft.entries.section('blog') which doesn't use your tag query. You simply need to loop through the results of your query which you've set in the entries ...
Luke Pearce's user avatar
  • 3,863
4 votes
Accepted

How to display number of entries for a tag and not display if no entries?

Something like this should work: {% set tags = craft.tags.limit(null).relatedTo(craft.entries.limit(null)).order('title') %} {% for tag in tags %} <a href="/tags/{{ tag.slug }}">{{ tag....
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Where are tags stored in the database?

Tags are Elements and are stored in multiple places in the database, so editing the db directly may not be as easy as just finding the Tags you want and deleting them. The tag itself is stored in ...
Ben Parizek's user avatar
  • 13.4k
3 votes

Tag mysteriously not found

You don't need to use the search parameter in this case. I'd avoid using it where ever possible. {% set tag = craft.tags.slug(slug).first() %}
carlcs's user avatar
  • 36.2k
3 votes

I would like to implement the remarketing tag into my website

I assume you're asking about AdWords? Forgive me if I need to ask this but who developed your website? It sounds like you need to have your developer add that bit to the website's code. (If you're ...
RitterKnight's user avatar
  • 6,582
3 votes
Accepted

Limit search results for users by tag (and limit to 5 tags)

There’s no way to tell the relatedTo param to only factor in the first X relations per source element (the first 5 tags per user, in this case). I can think of two ways you could accomplish this: ...
Brandon Kelly's user avatar
3 votes
Accepted

Correct way to merge craft.user field arrays and use outside the loop?

It looks like you have a typo in your merge, and the structure of the merge is incorrect. {% set merged = specialisms|merge(specialisms) %} This is saying set merged to the array specialisms merged ...
kcolls's user avatar
  • 608
3 votes

How do I delete a tag?

There is a third-party plugin called Tag Manager that let's you delete tags.
Alex Roper's user avatar
  • 2,622
3 votes
Accepted

Use of tag.slug instead of tag.title in a custom route

You do not have to change your route. Instead modify your template where you are linking the tag. Instead of using <a href="{{ siteUrl }}tags/{{ tag.title | url_encode }}">{{ tag.title }}, <...
Fyrebase's user avatar
  • 735
3 votes
Accepted

Tag overview in the Craft backend

There is a Tag Manager plugin you can use for this. You might also want to consider voting for this feature request if you think this should be in core!
Brad Bell's user avatar
  • 67.2k
3 votes
Accepted

Best method to handle %20 in tag URLs with multiple words

Update. After looking at the tag model a little more closely, it looks like tags have both a title and slug — so if you use the slug to construct your url then you shouldn't have that problem. For ...
Douglas McDonald's user avatar
3 votes
Accepted

List entries without specific tag

You could try something like following reducing the tagged entries into IDs that you then filter against (see this thread): {% set tag = craft.tags.search('All-Stars').first() %} {% set allEntries = ...
Cole Henley's user avatar
  • 1,741
3 votes

Most related articles

If you're only trying to find related articles based on elements (ie tags, categories, entries, etc), you can use my Similar plugin. Here's a basic example, more info in the repo: {% set ...
André Elvan's user avatar
  • 7,268
3 votes
Accepted

Get random entry tagged with

You could try customizing the order parameter. MySQL allows ordering randomly by using .. ORDER BY rand(). So you could try the following: craft.entries.section('featured').order('rand()').first()
pauliusef's user avatar
  • 163

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