I have a question about usage of previous_posts_link/next_posts_link. Is it possible to use it for custom post types too?

I like to hear from you.

Thanks in advance. Casper

  • 1
    Try it. What are your results?
    – fuxia
    Commented Apr 1, 2013 at 10:07
  • @toscho Notting is happening...
    – Casper
    Commented Apr 1, 2013 at 10:30
  • Are you referring to CPT archive page pagination or single CPT entries (next and previous single posts)? Commented Oct 5, 2014 at 12:28

3 Answers 3


This is the code that worked for me. I have a custom post type called "feature" defined like this:

$args = array(
    'label'               => 'feature',
    'description'         => 'Product feature pages',
    'labels'              => array(
        'name'                => 'Features',
        'singular_name'       => 'Feature',
        'menu_name'           => 'Feature',
        'parent_item_colon'   => 'Parent Feature:',
        'all_items'           => 'All Features',
        'view_item'           => 'View Feature',
        'add_new_item'        => 'Add New Feature',
        'add_new'             => 'New Feature',
        'edit_item'           => 'Edit Feature',
        'update_item'         => 'Update Feature',
        'search_items'        => 'Search Feature',
        'not_found'           => 'No Features found',
        'not_found_in_trash'  => 'No Features found in Trash',
    'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes', ),
    'taxonomies'          => array( 'category' ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'menu_icon'           => '',
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'feature',
register_post_type( 'feature', $args );

Then I create a file called single-feature.php in my theme folder, and inside that file I have:

<ul class="pager">
              <li class="previous">
                  previous_post_link( '%link', '<span class="meta-nav">' . _x( '&larr;', 'Previous feature', 'mistcrm' ) . '</span> %title' ); ?>
              <li class="next">
                  next_post_link( '%link', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next feature', 'mistcrm' ) . '</span>' ); ?>
  • Or if you didn't want to create a single-cpt.php file, you could simply hook in the links after the loop using the correct WordPress or theme specific hook and the conditional tag for your CPT. Commented Feb 8, 2014 at 8:58
  • In single-feature.php you only have the code you provided? (pager) no footer and other code to query your features ?
    – trainoasis
    Commented Feb 12, 2015 at 11:13

They do work.

Just make sure you include both of them INSIDE the loop. Otherwise it will never know what is previous/next.


I had used a plugin to create the custom post types and then found that none of the core functions would give me next / previous links to single custom posts.

I ended up writing a plugin that "seems" to work for me.


Let me know if you have success of fail, it should give you next / previous links inside a single custom post, I don't think It will work in custom taxonomy but let me know :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.