• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Add Pagination To Custom Post Type Archive Pages

Simply paste this PHP code at the end of your child themes functions.php file.

The code controls how many CPT items display per archive page. It adds previous and next page links after each archive page for custom post types

If you have published 18 single CPT pages, this code will create 3 paginated pages.

Change Your CPT Name in the code to the name you used to create a custom post type in your functions file.

To control how many single CPT entries display on each page, change the number 6 to suit your own requirements.

You could also modify this code for use on custom taxonomy type archive pages simply by changing the conditional tag from:

is_post_type_archive( 'Your CPT Name' )

to

is_tax( 'Your Taxonomy Name' )

This solution adds page navigation to a custom post type archive page assuming you have created your custom post type using this code in Genesis.

If you used any other code to register your CPT, you may need another solution.

Related Code Snippets

  • Modify Archive Page Navigation Links in Genesis

Custom Post Type

Reader Interactions

Comments

  1. lex says

    April 10, 2015 at 2:17 pm

    I got it working after I changed the number of blogs under reading settings to match to my template settings. My goodness.

    Log in to Reply
    • Brad Dalton says

      April 10, 2015 at 2:30 pm

      hahaha Good stuff Lex!

      Log in to Reply
  2. lex says

    April 10, 2015 at 2:02 pm

    I added pagination with the following code

    echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link
    	echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages );

    When I click them, url changes to …/vlogs/page/4/ no problem, but the pages stays the same. it always lists just the latest posts. Hmm…

    Log in to Reply
  3. lex says

    April 10, 2015 at 1:37 pm

    This works for the standard loop. How do I add pagination to a custom loop.


    remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
    add_action( 'genesis_loop', 'custom_do_grid_loop' ); // Add custom loop

    And I have my loop working, but I don’t have pagination

    Thank you.

    Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags