display posts in multiple columns sorted by categories

Asked

Viewed 372 times

0

As I have a limited knowledge of php, I would like to get a notion of the code needed to, in wordpress, achieve the following:

Assuming you have x categories, on the homepage of the site you should display x columns (one for category), where in each column the n most recent posts of each category should be displayed. on the pages of each category, must follow the same pattern, only each column will be related to the sub-categories of the parent category.

someone could give me some tips on how to do this, starting with which file I should change to put the necessary code to do this?

1 answer

0

I use it as follows:

<?php $args = array(
            'post_type' => 'noticia',
            'posts_per_page' => 3, //Número de posts
            'tax_query' => array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'noticias',
                    'field' => 'slug',
                    'terms' => array(
                        'regiao'// Categoria a ser exibida
                    )
                )
            )
        );
        $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post();?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.