• Resolved burlyqlady

    (@burlyqlady)


    Hi. I’v added this filter:

    /**
     * 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 ) {
        // Adding a post status.
        $post_statuses[] = 'publish';
    
        // Removing a post status.
        if ( isset( $post_statuses['draft'] ) ) {
            unset( $post_statuses['draft'] );
        }
    
        return $post_statuses;
    }
    add_filter( 'c2c_admin_post_navigation_post_statuses', 'change_apn_post_status' );

    to my theme’s functions file but it’s still navigating to posts that are drafts instead of published. Any help?

    https://www.ads-software.com/plugins/admin-post-navigation/

Viewing 1 replies (of 1 total)
  • Plugin Author Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    @burlyqlady : Hi,

    Sorry, it turns out I provided an incorrect example, so it was my fault and not yours! I’ve updated the example as part of the just-released v1.9.1. Here’s the updated version of your code snippet that should do what you want:

    /**
     * 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 ) {
    	// 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' );

    Thanks for bringing this up!

Viewing 1 replies (of 1 total)
  • The topic ‘Can't get filter to work’ is closed to new replies.