Plugin Author
Nicola Mustone
(@nicolamustone)
Automattic Happiness Engineer
Hello,
You can add this code in your functions.php file, at the end of the file (before the sign ?> if you have it):
add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' );
function wp_discord_post_limit_by_category( $post ) {
return has_category( 'Uncategorized', $post );
}
If you want to check multiple categories, use this:
add_filter( 'wp_discord_post_is_new_post', 'wp_discord_post_limit_by_category' );
function wp_discord_post_limit_by_category( $post ) {
return has_category( array( 'Category 1', 'Category 2' ), $post );
}
The post will be published to Discord only if it has the category specified there.
-
This reply was modified 7 years, 11 months ago by
Nicola Mustone. Reason: typo
Thanks! Forgive me im not the best with some coding… what in this code do I need to change to set the correct category?
In my case the category name I would like streamed is “Contributor”
Thanks.
Plugin Author
Nicola Mustone
(@nicolamustone)
Automattic Happiness Engineer
If it’s only one category use the first snippet in my previous reply, and replace the word Uncategorized with Contributor.
With my wordpress theme I can add code into the themes backend. CSS, HTML, Javascript. Will it be better if I put this in there?
Plugin Author
Nicola Mustone
(@nicolamustone)
Automattic Happiness Engineer
From your screenshot, it shows that it’s the wrong location.
Add the code at the very end of the file, after the last }. That should make the trick.
whoop! Thanks 100% works now π
After adding this code, no posts are pushed to discord. I’ve tried both a singular category and multiple categories in an array. When I remove the code, all posts are pushed.
I’ve tried this code in both the theme functions.php file as well as using the “Snippets” plugin.
For a member’s only site, adding the ability to select which categories are pushed to discord from within the dashboard settings would be very helpful.