How to display entries from a specific wordpress categories in two columns?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
14 views
There is a code-example with the output I understand all the entries on the page, and I need to display the records not all, but from a specific category (id=5, name - skills). Please tell me how to do it?
<?php if (have_posts()) { ?><?php $i = 0; ?><?php $per_column = ceil($posts_per_page / 2); ?><?php if ($wp_query->post_count <= $posts_per_page) $per_column = ceil($wp_query->post_count / 2); ?> <?php while (have_posts()) { the_post(); $i++; ?><?php the_title(); ?><?php the_time('d.m.Y') ?><?php the_excerpt(); ?><!-- .post --><?php if ($i == $per_column) { ?><!-- .column --><?php } ?><?php } ?><!-- .column --><?php } ?>


PS Found a solution finally

<?php $args = array('post_type' => 'skills', 'post_status' => 'publish' ); $skills_loop = new WP_Query( $args ); ?> <?php if ($skills_loop->have_posts()) { ?> <?php $i = 0; ?><?php $per_column = ceil($posts_per_page / 2); ?><?php if ($skills_loop->post_count <= $posts_per_page) $per_column = ceil($skills_loop->post_count / 2); ?> <?php while ($skills_loop->have_posts()) { $skills_loop->the_post(); $i++; ?> <?php echo $i; ?><?php the_title(); ?><?php if ($i == $per_column) { ?><!-- .column --><?php } ?><?php } ?><!-- .column --><?php } ?>
by | 14 views

1 Answer

0 like 0 dislike
Display articles in 2 columns in different ways.
1) placing a PHP counter
2) method the css property column-count

Useful article - wordsmall.ru/bez-plagina/vyvodim-posty-v-dve-kolon...
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 11, 2019 by ronni10
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,593 users