I have a custom post type and custom taxonomy. The taxonomy works like a category system. Users can add the custom posts to the categories. There is one page per each category, displaying the posts in that category.
I need to get the page slug of the current category page. How can I do this please?
For example, my url is: ?event-categories=day-courses
.
event-categories is the custom taxonomy.
This code would work if I only had ‘day-courses’ in this custom taxonomy, which I do not:
<?php
global $post;
$post_slug=$post->post_name;
echo $post_slug;
$my_query = new WP_Query( array( 'post_type' => 'event', 'event-categories' => 'day-courses' ) );
while ($my_query->have_posts()) : $my_query->the_post();
?>
<div>
<h2><a href="https://wordpress.stackexchange.com/questions/175108/<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div>
<?php endwhile; ?>