WordPress.org

Plugin Directory

Admin Post Navigation

Adds links to navigate to the next and previous posts when editing a post in the WordPress admin.

Filters

The plugin is further customizable via six filters. Typically, these customizations would be put into your active theme's functions.php file, or used by another plugin.

c2c_admin_post_navigation_orderby (filter)

The 'c2c_admin_post_navigation_orderby' filter allows you to change the post field used in the ORDER BY clause for the SQL to find the previous/next post. By default this is 'ID' for non-hierarchical post types (such as posts) and 'post_title' for hierarchical post types (such as pages). If you wish to change this, hook this filter. This is not typical usage for most users.

Arguments:

  • $field (string) The current ORDER BY field
  • $post_type (string) The post type being navigated

Example:

/**
 * Modify how Admin Post Navigation orders posts for navigation by ordering
 * pages by 'menu_order' and posts by 'post_date'.
 *
 * @param string $field     The field used to order posts for navigation.
 * @param string $post_type The post type being navigated.
 * @return string
 */
function custom_order_apn( $field, $post_type ) {
    if ( 'page' === $post_type ) {
        return 'menu_order';
    } else {
        return 'post_date';
    }
}
add_filter( 'c2c_admin_post_navigation_orderby', 'custom_order_apn', 10, 2 );

c2c_admin_post_navigation_post_statuses (filter)

The 'c2c_admin_post_navigation_post_statuses' filter allows you to modify the list of post_statuses used as part of the search for the prev/next post. By default this array includes 'draft', 'future', 'pending', 'private', and 'publish'. If you wish to change this, hook this filter. This is not typical usage for most users.

Arguments:

  • $post_statuses (array) The array of valid post_statuses

Example:

/**
 * Modify Admin Post Navigation to allow and disallow certain post statuses from being navigated.
 *
 * @param array $post_statuses Post statuses permitted for admin navigation.
 * @return array
 */
function change_apn_post_status( $post_statuses ) {
    // Add a post status.
    // Note: by default these are already in the $post_statuses array: 'draft', 'future', 'pending', 'private', 'publish'
    $post_statuses[] = 'trash';

    // Remove post status(es).
    $post_statuses_to_remove = array( 'draft' ); // Customize here.
    foreach ( $post_statuses_to_remove as $remove ) {
        if ( false !== $index = array_search( $remove, $post_statuses ) ) {
            unset( $post_statuses[ $index ] );
        }
    }

    return $post_statuses;
}
add_filter( 'c2c_admin_post_navigation_post_statuses', 'change_apn_post_status' );

c2c_admin_post_navigation_post_types (filter)

The 'c2c_admin_post_navigation_post_types' filter allows you to modify the list of post_types used as part of the search for the prev/next post. By default this array includes all available post types. If you wish to change this, hook this filter.

Arguments:

  • $post_types (array) The array of valid post_types

Examples:

/**
 * Modify Admin Post Navigation to only allow navigating strictly for posts.
 *
 * @param array $post_types Post types that should have admin post navigation.
 * @return array
 */
function change_apn_post_types( $post_types ) {
    return array( 'post' );
}
add_filter( 'c2c_admin_post_navigation_post_types', 'change_apn_post_types' );
/**
 * Modify Admin Post Navigation to disallow navigation for the 'recipe' post type.
 *
 * @param array $post_types Post types that should have admin post navigation.
 * @return array
 */
function remove_recipe_apn_post_types( $post_types ) {
    if ( isset( $post_types['recipe'] ) ) {
        unset( $post_types['recipe'] ); // Removing a post type
    }
    return $post_types;
}
add_filter( 'c2c_admin_post_navigation_post_types', 'remove_recipe_apn_post_types' );

c2c_admin_post_navigation_prev_text (filter)

The 'c2c_admin_post_navigation_prev_text' filter allows you to change the link text used for the 'Previous' link. By default this is '← Previous'.

Arguments:

  • $text (string) The 'previous' link text.

Example:

/**
 * Changes the text for the 'previous' link to 'Older' output by the Admin Post Navigation plugin.
 *
 * @param string $text The text used to indicate the 'next' post.
 * @return string
 */
function my_c2c_admin_post_navigation_prev_text( $text ) {
    return 'Older';
}
add_filter( 'c2c_admin_post_navigation_prev_text', 'my_c2c_admin_post_navigation_prev_text' );

c2c_admin_post_navigation_next_text (filter)

The 'c2c_admin_post_navigation_next_text' filter allows you to change the link text used for the 'Next' link. By default this is 'Next →'.

Arguments:

  • $text (string) The 'next' link text.

Example:

/**
 * Changes the text for the 'next' link to 'Newer' output by the Admin Post Navigation plugin.
 *
 * @param string $text The text used to indicate the 'next' post.
 * @return string
 */
function my_c2c_admin_post_navigation_next_text( $text ) {
    return 'Newer';
}
add_filter( 'c2c_admin_post_navigation_next_text', 'my_c2c_admin_post_navigation_next_text' );

c2c_admin_post_navigation_display (filter)

The 'c2c_admin_post_navigation_display' filter allows you to customize the output links for the post navigation.

Arguments:

  • $text (string) The current output for the prev/next navigation link

Example:

/**
 * Change the markup displayed by the Admin Post Navigation plugin.
 *
 * @param string $text The text being output by the plugin.
 * @return string
 */
function override_apn_display( $text ) {
    // Simplistic example. You could preferably make the text bold using CSS.
    return '<strong>' . $text . '</strong>';
}
add_filter( 'c2c_admin_post_navigation_display', 'override_apn_display' );

Requires: 3.0 or higher
Compatible up to: 4.3
Last Updated: 2015-8-19
Active Installs: 10,000+

Ratings

4.8 out of 5 stars

Support

2 of 2 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,3,3
100,2,2 100,1,1
50,2,1 100,1,1
100,3,3
100,1,1
75,4,3
100,1,1
100,1,1
100,1,1 100,1,1
100,3,3
100,2,2
100,1,1
100,2,2
100,1,1
100,2,2
100,2,2
100,2,2 100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
100,1,1