<?php /** * The template part for displaying cartegories cards of home page * */ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; $posts_page_link = get_field("") ?> <div class="postsCatsNav__wrapper"> <nav role="navigation" aria-label="Categories"> <div class="postsCatsNav__filter"> <span class="fas fa-filter"></span> <span class="paragraph">Filter:</span> </div> <a href="<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>" class="postsCatsNav__filterItem <?php echo (is_home() ? "--active" : "") ?>"> <span class="fas fa-clone"></span> <span class="paragraph">Alt</span> </a> <?php $available_cats = get_categories(); $filter_query = new WP_Query; foreach ( $available_cats as $category ) : $filter_query->query( array( 'cat' => $category->term_id, 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, )); while( $filter_query->have_posts() ): $filter_query->the_post(); ?> <a href="<?php echo get_term_link($category->term_id)?>" class="postsCatsNav__filterItem <?php echo (is_category( $category->name ) ? "--active" : "" )?>"> <?php echo process_post_cat(get_the_ID(), false); ?> <span class="paragraph"><?php echo esc_html( $category->name )?></span> </a> <?php endwhile; ?> <?php endforeach; ?> </nav> </div>