Home Wordpress Use paginate_links() on custom post type

Use paginate_links() on custom post type

by Ker

paginate_links() functions let us place paginate links on any part of the website. But when we use it on custom type, we have to specifically input some hook into paginate_links() because it is working on archive post type by default.

For Example eco out the paginale_links() underneath the content:

    echo paginate_links([
    'total' => $objectName->max_num_pages()

Make sure we have included ‘paged’ inside the WP_Query() before we use paginate_links() so we are able to get the page ready to load:

// dynamic getting the current page based on the URL, and 1 for the first page
$objectName = new WP_Query([
   'paged' => get_query_var('paged', 1)



Related Videos

Leave a Comment

Our mission: to help people learn web development and leverage the power of WordPress.