Skip to content

Instantly share code, notes, and snippets.

@oliwa
Last active December 5, 2018 07:11
Show Gist options
  • Save oliwa/1b45d803afb1033c31be to your computer and use it in GitHub Desktop.
Save oliwa/1b45d803afb1033c31be to your computer and use it in GitHub Desktop.
Collection of usefull snippets for the functions.php
// adding blogname to body_class(),
// see http://www.be-studios.com/blog/2012/11/wordpress-multisite-adding-blogname-to-body_class/
add_filter('body_class', 'multisite_body_classes');
function multisite_body_classes($classes) {
$id = get_current_blog_id();
$slug = strtolower(str_replace(' ', '-', trim(get_bloginfo('name'))));
$classes[] = $slug;
$classes[] = 'site-id-'.$id;
return $classes;
}
// unautop for images,
// see http://wpengineer.com/2264/replace-p-tag-on-images-in-content-of-wordpress/
function fb_unautop_4_img( $content ) {
$content = preg_replace(
'/<p>\\s*?(<a rel=\"attachment.*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s',
'<figure>$1</figure>',
$content
);
return $content;
}
add_filter( 'the_content', 'fb_unautop_4_img', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment