Numeric pagination custom post type

i create a custom page to display loop of cpt with custom field. I need to add a numberic pagination and i try with this code but not work. Functions.php function pagination_bar() { global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1){ $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘base’ => get_pagenum_link(1) . ‘%_%’, ‘format’ => … Read more

When should you use wp_reset_postdata vs wp_reset_query?

Seems like half the tutorials in the Codex use wp_reset_postdata() and half use wp_reset_query(). What’s the deal? Maybe Use both of them? What about rewind_posts()? I am asking for an answer based on facts, not on opinions. 1 Answer 1 wp_reset_postdata() resets the value of the global $post variable to the post property of the … Read more

Why should i use wp_reset_postdata()?

I am not able to understand the use of wp_reset_postdata. what could go wrong if i am not using it? https://codex.wordpress.org/Function_Reference/wp_reset_postdata Here in documentation what is main query and secondary query? Thanks 1 Answer 1 WordPress uses global $post variable. This way you don’t have to pass post nor post_ID as param for functions. So … Read more

wp_reset_postdata() or wp_reset_query() after a custom loop?

Reading some stuff about query_reset_postdata and query_reset_query makes me confused. For example: Is there any need to use both wp_reset_postdata and wp_reset_query together? http://www.poststat.us/properly-reset-wordpress-query/ Above states that you should only use query_reset_postdata() when using “separate queries”. In example2 there’s a comment: WP_Query( $args ) = wp_reset_postdata(); AND query_posts ( $args ) = wp_reset_query(); And really … Read more