0
I’m creating a loop where I want to display only content that contains the Slug page. I’m not sure which variable to put inside the array $args
to make the Slug of the page itself be the category to be displayed.
I have a function that allows me to use <?php the_slug(); ?>
, returning the Slug of the page, but I’m not sure how to put this in the 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;
?>
It wouldn’t just be
'category_name' => the_slug()
?– Woss