Last active
July 31, 2020 17:00
-
-
Save brandondove/470fb3a01fa9b74362f8dc78296d904c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allows you to modify the css classes that are applied to an ad unit so you can style each unit individually | |
*/ | |
function example_adsanity_post_class( $classes = array(), $post = false ) { | |
// Adds a dynamic class that utilizes data from the post object | |
if ( FALSE !== $post && $post instanceof WP_Post ) { | |
$classes[] = sprintf( 'custom-%d', $post->ID ); | |
} | |
// Adds a static class to all ads | |
$classes[] = 'special-ad'; | |
return $classes; | |
} | |
add_filter( 'adsanity_post_class', 'example_adsanity_post_class', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have a typo on line 8.
Should be: