Clearfix Shortcode

Here’s the code to be added to functions.php. As a bonus I’ve included a shortcode for a horizontal rule <hr>: function shortcode_hr() { return ‘<hr>’; } function shortcode_clearfix() { return ‘<div style=”display: block; visibility: hidden; clear: both; height: 0;”></div>’; } function register_shortcodes() { add_shortcode(‘hr’, ‘shortcode_hr’); add_shortcode(‘clearfix’, ‘shortcode_clearfix’); } add_action( ‘init’, ‘register_shortcodes’); Nothing complicated here, so … Read more

Two column layout in WordPress?

This is not really a WordPress question but my first plugin solution is a “WordPress” way to do it. My other solutions are more general web design. I’m also making the assumption that you have some experience with custom templates/scripts. If you want to manually do it you can use something like Grid Columns This … Read more

Different layout based on post amount?

for a standard query, you can check the amount of posts with: all posts for the query: $wp_query->found_posts and the posts on the page: $wp_query->post_count use that with a conditional statement to switch to the different layouts. example: <?php if ( have_posts() ) : //start of the loop// if ( $wp_query->found_posts <= 4 ) { … Read more