F
F
Freeto2018-04-04 18:50:02
WordPress
Freeto, 2018-04-04 18:50:02

How to display products by category on the catalog page?

Displaying products by category on the catalog page. It is necessary that the name of the category would first go, then the products of this category. I don't know how to implement this functionality.
I would implement everything using shortcodes, but then the ajax filter through the plugin does not work. It works, of course, but it already redirects to the same page ... Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xXRustamXx, 2018-04-04
@xXRustamXx

<?php
        // параметры по умолчанию
        $args = array(
          'numberposts' => 4, // Число постов
          'category_name'    => 'name', // Имя категории
          'order'       => 'DESC',
          'post_type'   => 'post'
        );
        $posts = get_posts($args);

        foreach($posts as $post){ setup_postdata($post);?>

            <div class="post_item">
                                        <?php the_content(); ?>
            </div>

        <?php }
          wp_reset_postdata();
        ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question