Rendering pages

The WordPress template hierarchy is your friend. https://developer.wordpress.org/themes/basics/template-hierarchy/ This provides a very detailed flow for how WP determines which template to load. If you are ever uncertain about which template is loading, this little function is handy. Paste in your theme’s functions.php and it will display the template used at the bottom of the page. … Read more

How to separate posts loop in to two columns? [duplicate]

<?php $row_start = 1; while ( have_posts() ) : the_post(); if( $row_start % 2 != 0) {// odd ?> <div class=”left-side”> <?php get_template_part( ‘blog’,’item’); ?> </div> <?php } if( $row_start % 2 == 0) {// even ?> <div class=”right-side”> <?php get_template_part( ‘blog’,’item’);?> </div> <?php } ++$row_start; endwhile; ?> You could always break in and out … Read more

Random post link generator messes up the loop

Ok, thanks to The Maniac for all the help troublshooting. Looks like I had to take this completely outside the loop and call the WP_Query class on a new variable to make it happen. Here’s what worked: <?php $query = new WP_Query( array ( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’ ) ); while ( $query->have_posts() … Read more

How is WordPress changing the content markup?

WordPress runs a filter on the content to automatically add paragraphs: wpautop. You can remove the filter from all your post’s content if you like: remove_filter(‘the_content’,’wpautop’); Alternatively, you can check out the Disabler plugin which can do this for you. If you want to remove the filter from particular post(s) you can do: add_filter(‘the_content’,’maybe_remove_wpautop’,9); function … Read more

Exclude page from loop results

You need the WP_Query documentation. WP_Query is very powerful, and you can do a lot with it 🙂 In your case, I don’t think exclude is a valid parameter. What you’re probably looking for is this: $query->set( ‘post__not_in’, array( 34 ) ); Here’s the Post & Page Parameters section of the documentation, which covers this … Read more