PHP code printed into CSS classes

Well, previous developer was a little bit naughty (;)) and used PHP short tags, which is a bad practice… And even worse – he used them a little bit wrong, I guess… As you can see, there is something like this in your code: style=”<?print implode(‘;’,$styles); ?>”> Of course there is no such thing like … Read more

How to wrap image tag into div for post only?

You have the global WP_Post object available so you can look the post type like this: function wrap_post_images_to_div( $content ) { if ( get_post()->post_type === ‘post’ ) { $pattern = ‘/(<img([^>]*)>)/i’; $replacement=”<div class=”well text-center”>$1</div>”; $content = preg_replace( $pattern, $replacement, $content ); } return $content; } add_filter( ‘the_content’, ‘wrap_post_images_to_div’ ); You can use the preg_replace_callback instead … Read more

Why .widget-area is outside of .site-content in Underscores starter theme?

The .widget-area actually IS inside .site-content. For anyone wondering why .content-area has a <main> child-element, rather than being the <main> element itself, here is the explanation: It allows for CSS styling while preserving HTML5 semantics. Namely it allows for easier negative margin management as well as background and other styling (full explanation here).