I'm trying to pull all of the categories associated with a custom post type within a loop, but I'm not sure how to get it so automatically pulls all of the categories automatically from the associated post type?
My reason is that if a user wants to add/remove a category from the custom post type, I don't want to have to edit the template file to manually add or remove the category name.
I currently have this:
<?php $args = array( 'post_type' => 'rentals'); $loop = new WP_Query( $args ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post();?> <div class="fg12 rentals"> <h2><?php the_title(); ?></h2> <div class="info"> <?php category_description(); ?> <a class="button" href="<?php the_field('rental_item_link') ?>"> Learn More → </a> </div> </div> <?php endwhile; wp_reset_query(); ?>
And I know if I add
'category_name' => 'cat-slug1, cat-slug2, etc...' it will pull those specific categories, but I'm trying to avoid doing that manually in case someone wants to add or remove a specific category.
I'm also trying to get the category description as well, but I'm not sure if I am pulling that correctly either.
I hope that makes sense.