Created
November 13, 2018 15:08
-
-
Save luisfelipe-dev/beb5d3dc8d833b8082a53bc0ba7fdac5 to your computer and use it in GitHub Desktop.
Loop para adicionar o nome da categoria na classe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $args = array( | |
| 'post_type' => 'post', | |
| 'posts_per_page' => 100, | |
| 'orderby' => 'date', | |
| 'order' => 'DESC' | |
| ); | |
| $loop = new WP_Query( $args ); | |
| while ( $loop->have_posts() ): | |
| $loop->the_post(); | |
| $postcat = get_the_category(); | |
| if ( ! empty( $postcat ) ) { | |
| $category = $postcat[0]->slug ; | |
| $category_name = $postcat[0]->name ; | |
| } | |
| ?> | |
| <div class="<?= $category ?>"> | |
| </div> | |
| <?php endwhile; ?> | |
| <?php wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment