Title: Can&#039;t set multiple classes
Last modified: August 30, 2016

---

# Can't set multiple classes

 *  [jamesrandom](https://wordpress.org/support/users/jamesrandom/)
 * (@jamesrandom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/cant-set-multiple-classes/)
 * I have tried to set the date_class to apply multiple classes to the date (to 
   match other pages) but this doesn’t work. For example, I use
    `date_class="postdate
   bg-lightgray headerfont postmeta updated"` But the class names all get concatenated
   so the result is `<div class="postdatebg-lightgrayheaderfontpostmetaupdated">`
 * I can work around this by creating a new class and copying the attributes but
   that is not so convenient.
 * [https://wordpress.org/plugins/list-category-posts/](https://wordpress.org/plugins/list-category-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [jamesrandom](https://wordpress.org/support/users/jamesrandom/)
 * (@jamesrandom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/cant-set-multiple-classes/#post-6846156)
 * Having looked at the source, this is because it uses sanitize_html_class() to
   make sure the class is valid/safe. However, this doesn’t allow spaces. There 
   is an update of this function in progress to allow a wider range of characters.
   I have posted to the bug tracker suggesting it should also allow spaces.
    [https://core.trac.wordpress.org/ticket/33924](https://core.trac.wordpress.org/ticket/33924)
 *  Thread Starter [jamesrandom](https://wordpress.org/support/users/jamesrandom/)
 * (@jamesrandom)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/cant-set-multiple-classes/#post-6846240)
 * The response to that bug report suggests using esc_attr() instead of sanitize_html_class().
   I have modified the code and this works exactly as I need. I don’t know if you
   want to make the change in your code or not …

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can't set multiple classes’ is closed to new replies.

 * ![](https://ps.w.org/list-category-posts/assets/icon-256x256.png?rev=2517221)
 * [List category posts](https://wordpress.org/plugins/list-category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/list-category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-category-posts/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [jamesrandom](https://wordpress.org/support/users/jamesrandom/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/cant-set-multiple-classes/#post-6846240)
 * Status: not resolved