-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homepage Posts: add category, tag classes to each article #487
Conversation
foreach ( $tags as $tag ) { | ||
$classes[] = 'tag-' . $tag->slug; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this logic of assigning tag and category classes be moved to Newspack_Blocks
(like prepare_authors
is) to avoid duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good call, Adam! I've updated it to live in Newspack_Blocks in 04f01c3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, there's just a doc comment change needed!
class-newspack-blocks.php
Outdated
@@ -411,6 +411,32 @@ public static function prepare_authors() { | |||
); | |||
} | |||
|
|||
/** | |||
* Prepare an array classes based on assigned tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: tags and categories ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, thanks for catching that Adam! 🤦♀️ Fixed in 2bf0c3d.
class-newspack-blocks.php
Outdated
* Prepare an array classes based on assigned tags. | ||
* | ||
* @param string $post_id Post ID. | ||
* @return array Array of CSS classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return array Array of CSS classes. | |
* @return string CSS classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed in 2bf0c3d, too -- the comment cleanup commit 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Yay! Thanks for help hammer this into shape! |
# [1.7.0](v1.6.0...v1.7.0) (2020-06-02) ### Features * add category and tag classes to each homepage post ([#487](#487)) ([d7c4fcd](d7c4fcd))
🎉 This PR is included in version 1.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
This PR adds classes based on each post's assigned category and tag to the
<article>
tag, using the same format that is output by the[post_class()](https://developer.wordpress.org/reference/functions/post_class/)
function. (I opted not to use that function as it's more likely to output classes -- liketype-post
orhas-post-thumbnail
-- that themes could already be using. The tag and category classes are most likely to be used on a site-by-site basis to customize specific taxonomies).This change will make it possible to add custom CSS to posts with specific categories or tags within a block, rather than assigning custom CSS to all posts in a block based on a class added to that block.
Closes #363.
How to test the changes in this Pull Request:
npm run build
.<article>
tag has classes assigned based on the categories the post has (using the formatcategory-[slug]
), and classes assigned based on the tags the post has (using the formattag-[slug]
).<article>
tag has the same classes assigned based on each post's categories and tags.Other information: