WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Try it. What are your results? – toscho Apr 1 '13 at 10:07
@toscho Notting is happening... – Casper Apr 1 '13 at 10:30
Are you referring to CPT archive page pagination or single CPT entries (next and previous single posts)? – Brad Dalton Oct 5 '14 at 12:28

They do work.

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

share|improve this answer

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>' ); ?>
share|improve this answer
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. – Brad Dalton Feb 8 '14 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 Feb 12 '15 at 11:13

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 :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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