Shortcode atts for WP Query args
Question
I need to create a shortcode for display CPT posts. I want to add an atts that print the number of posts_per_page I need in the args for Wp_query. But If I use [short_events number=5], it print only one post. Where I’m Wrong?
function dis_short_events($atts, $content = null){
ob_start();
$numero = extract(shortcode_atts(array(
'number' => '-1',
), $atts));
$args =array(
'post_type'=>'eventi',
'posts_per_page' => $numero
);
............
add_shortcode('short_events', 'dis_short_events');
0
php, shortcode, wordpress.org
4 years
2020-03-23T20:54:02-05:00
2020-03-23T20:54:02-05:00 0 Answers
120 views
0
Leave an answer