wickywills
8/31/2017 - 11:14 AM

Store a return function

Store a return function

I needed to store a function that would otherwise echo for use in a Twig template:

function doPagination($cpt_query){
    wp_pagenavi( array( 'query' => $cpt_query ) ); 
}

ob_start();
doPagination($cpt_query);
$context['pagination'] = ob_get_contents();
ob_end_clean();