Home › Forums › Calendar Products › Events Calendar PRO › [tribe_events] Shortcode Limit option not Working › Reply To: [tribe_events] Shortcode Limit option not Working
January 12, 2017 at 4:43 am
#1217300
Eric
Participant
Added a vote to the uservoice topic!
Just a quick note how you can achieve this in a kind of hacky way. Add the following code to your functions.php to change the number of posts in a shortcode:
function sif_tribe_option($option, $optionName, $default) {
//change number of posts per page
$numberOfPostsInShortcode = 3;
if($optionName == 'postsPerPage') {
//are we in a shortcode?
$in_shortcode = in_array(
'do_shortcode',
wp_list_pluck(
debug_backtrace(),
'function'
)
);
if($in_shortcode) {
return $numberOfPostsInShortcode;
} else {
return $option;
}
}
//always return an option
return $option;
}
add_filter('tribe_get_option', 'sif_tribe_option', 10, 3);