WordPress theme files Organization

It seems like the WordPress community really loves this mix of PHP and HTML together, and as you say it often leads to very hard to understand and maintain code. It is a common programming pattern to separate out ‘logic’ and ‘presentation’. Logic here is PHP code which makes decisions, presentation is HTML. I strongly … Read more

Display all categories including sub categories under a list ul

Do you know how recursive functions are working? Here is an example: function get_categories_list( $parent ) { $args = array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘parent’ => $parent ); $current_level_categories = get_terms( $args ); $result=””; if ( $current_level_categories ) { foreach ( $current_level_categories as $cat ) { if ( $cat->name == ‘Uncategorized’ ) continue; … Read more

Why is my archive page looping through all but one post?

As @Jacob Peattie says, pagination is what’s causing this, and probably what you want to add if you will have more posts over time. If you want you can disable pagination for archive pages easily with this in your functions.php: function wpse_disable_pagination( $query ) { if (is_archive()) { $query->set(‘nopaging’, 1 ); } } add_action( ‘pre_get_posts’, … Read more

How to display fields from the loop in two separate divs

A simple solution would be just run the loop twice. <?php // set loop $args here so they’re in once place ?> <div class=”four”> <?php // run the loop once with $args, output left side items ?> </div> <div class=”five”> <?php // run the loop again with $args, output right side items ?> </div>