My shortcode does not call the function

I’m trying to make a shortcode with two parameters $number_posts and $category_name.

The shortcode is calling another function named bg_make_post_grid that uses those parameters as variables.

I added wp_die() to the function to see if it was being called, and it does not kill WordPress so I don’t think the function is being called.

What am I doing wrong?

// Add Shortcode
add_shortcode( ‘bg_recent_post_grid’, ‘bg_recent_post_grid_shortcode’ );
function bg_recent_post_grid_shortcode( $atts ) {

// Attributes
$atts = shortcode_atts(
array(
‘category_name’ => ‘uncategorized’,
‘number_posts’ => ‘1’,
), $atts );

return bg_make_post_grid ( $atts[‘number_posts’], $atts[‘category_name’] );

}

function bg_make_post_grid ( $number_posts, $category_name ) {

$args = array(
‘numberposts’ => $number_posts,
‘category’ => $category_name,
‘orderby’ => ‘post_date’,
‘order’ => ‘DESC’,
‘post_type’ => ‘post’,
);

$recent_posts = wp_get_recent_posts( $args );

wp_die();

}

Read more here:: My shortcode does not call the function

Leave a Reply

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