I'm trying to format each post that the user uploads.

I need the paragraphs to be floated to the left in the first column, and the images to be in a floated left in the second column.

(I've tried posting an image, but I need at least 10 reputation)

I am new to Wordpress development, so I apologise if this is a silly question.


There are multiple ways to that but what I like to do is to create shortcodes e.g [one_half] :

function one_half_sh( $atts, $content = null ) {
return '<div class="one-half">' . do_shortcode($content) . '</div>';
add_shortcode( 'one_half', 'one_half_sh' );

Then the CSS can look like this :

.one-half {
width: 48%;
margin: 0 4% 0 0;
float: left;

The second column would have the same markup but with 0 margin. This allows to set a very flexible layout you can customize on each post.

EDIT: for the second column just create another shortcode with exactly the same code but add a CSS class such as .second-col you will style in your stylesheet

  • Thanks. Where abouts would the function be placed— where within index.php? – tmyie Aug 8 '13 at 19:16
  • no within functions.php of the current theme – JMau Aug 8 '13 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.