Shortcode “post_per_page” not working

I managed to make this shortcode work and it shows everything as I want. The only issue I am facing right now is that if I use “posts_per_page => 1″, it keeps showing all the posts. What can I do to be able to show only the latest post of the category? I tried: posts_per_page => 1 without ”, but nothing it’s still not working.

Here’s the code I am using:

function Arte($atts, $content = null) {
“pagination” => ‘false’,
“query” => ”,
“category” => ‘arte’,
“posts_per_page” => ‘1’,
), $atts));

global $wp_query,$paged,$post;

$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();

if ($pagination == ‘true’) {
$query .= ‘&paged=’.$paged;

if (!empty($category)) {
$query .= ‘&category_name=’.$category;

if (!empty($query)) {
$query .= $query;


<ul class=”loop”>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark”>
<div class=”cont-overlay”><?php the_post_thumbnail(‘ilRaccoglitore_single’, array(‘class’ => ‘img-thumb-sidebar’,’alt’ => get_the_title())); ?>
<div class=”overlay”></div></div>

<?php if ($pagination == ‘true’) { ?>
<div class=”navigation”>
<div class=”alignleft”><?php previous_posts_link(‘” Previous’) ?></div>
<div class=”alignright”><?php next_posts_link(‘More »’) ?></div>
<?php } ?>

$wp_query = null; $wp_query = $temp;

$content = ob_get_contents();


return $content;


add_shortcode(“arte”, “Arte”);

Thank you in advance!

Read more here:: Shortcode “post_per_page” not working

Leave a Reply

Your email address will not be published. Required fields are marked *