I'm creating a loop where I want to display only content that contains the slug category of the page. I'm not sure what variable to put inside the array $args
to make the slug of the page itself the category to display.
I have a function that allows me to use <?php the_slug(); ?>
, returning the slug from the page, but I'm not sure how to put this in loop .
I have the following code:
<?php
$args = array('category_name'=>'<?php the_slug(); ?>', 'showposts'=>4);
$my_post = get_posts( $args );
if($my_post) : foreach ($my_post as $post) : setup_postdata( $post );
?>
<div class="col-xs-6 col-sm-6 col-lg-3"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?><p><?php the_title(); ?></p></a></div>
<?php
endforeach;
endif;
?>