The structure in page-bulletins.php
:
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
'paged' => $paged
);
$query = new WP_Query($args); if( $query->have_posts() ) :
while( $query->have_posts() ) : $query->the_post();
<!-- some code -->
endwhile;
// call the function 'posts_per_page' in the class 'cn_pages' using the value defined with the 'posts_per_page' key in '$args' above
cn_pages::posts_per_page($args['posts_per_page']);
// then call this function
pass_page_info();
endif;
The code in functions.php
:
class cn_pages {
function posts_per_page($postsperpage) {
return $postsperpage;
}
}
I have another function defined outside of the class cn_pages
that needs the result of the posts_per_page
method in order to calculate how many total pages there are.
How can I store the result of this method into a variable that I can access outside of the class where the method is defined?