Forum

Thread tagged as: Question, Blog

Setting a default category for new blog posts

I have a checklist of 3 categories that can be assigned to a blog post.

Is there a way to set or preselect a category when a new blog post is created?

(I had set 'required' to the checklist as a workaround, but if you go to the trouble of writing a long blog post and publish, the page refresh indicating that a category is required wipes out your text).

Winston Grace

Winston Grace 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

No, there's no way to automatically assign a default category.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Winston,

If you know the category ID, you can use the default attribute on the categories tag to have it selected by default:

<perch:categories id="categories" set="blog" label="Categories" default="4">

Note this does not work with display-as="checkboxes".

Brilliant! That'll do nicely.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does that work? Nice!

Yep, just tested - pre-populates the select menu with the specified category.