A snippetclub.com member was using the great Block Visibility plugin by Nick Diego, however they came across a scenario where they wanted to show or hide sponsored widgets in the sidebar of a blog post, based on the author of the post. The Block Visibility plugin doesn’t have any built in way to conditionally show or hide blocks based on the author.
The snippet below allows you to add the class author-USERNAME
or author-ID
to a block and it will conditionally show based on if the post author matches the username or user ID.
1. Add the code snippet
Add the code below to functions.php
or code snippet plugin.