Untitled
raw download clone
TEXT
views 23
,
size 2482 b
<?php


                //for each category, show 5 posts
                $cat_args = array(
                    'orderby' => 'name',
                    'orderby' => 'id',
                    'order' => 'ASC'
                );
                $counter = 0;
                $categories = get_categories($cat_args);
                foreach ($categories as $category) {
                    $counter++;
                    $image = get_field('dodaj_zdjecie_kategorii', $category->taxonomy . '_' . $category->term_id);
                    if ($counter % 2 == 0) { ?>
            <div class="single-categories-2 col-md-12 col-12 p-0">
                <div class="single-categories-inside col-md-12 col-12 p-0">
                    <div class="container">
                        <div class="row">
                            <a class="single-categories-image col-md-6 col-12" href="<?php echo get_category_link($category->term_id); ?>">
                                <img src="<?php echo $image; ?>">
                            </a>


                            <div class="single-categories-description col-md-6 col-12">
                                <h2><?php echo $category->name; ?></h2>
                                <p><?php echo category_description($category->term_id); ?></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <?php } else { ?>
            <div class="single-categories-1 col-md-12 col-12 p-0">
                <div class="single-categories-inside col-md-12 col-12 p-0">
                    <div class="container">
                        <div class="row">
                            <div class="single-categories-description col-md-6 col-12">
                                <h2><?php echo $category->name; ?></h2>
                                <p><?php echo category_description($category->term_id); ?></p>
                            </div>
                            <a class="single-categories-image col-md-6 col-12" href="<?php echo get_category_link($category->term_id); ?>">
                                <img src="<?php echo $image; ?>">
                            </a>
                        </div>
                    </div>
                </div>

            </div>
            <?php }
                    ?>


            <?php } // foreach($categories
            ?>
close fullscreen
Login or Register to edit or fork this paste. It's free.