Home Forums Backend Issues (wp-admin) Not compatible with this code? Reply To: Not compatible with this code?

  • Hi

    Interestingly only a day later than the last post I came looking for an answer to exactly the same question. I seem to have solved the problem, well at least for myself I have in this way…

    function posts_for_current_author($query) {
    	if( !$query->is_admin )
    		return $query;
    	$screen = get_current_screen();
    	if ($screen->base === 'post')
        		return $query;
    	if( !current_user_can( 'moderate_comments' ) ) {
    		global $user_ID;
    		$query->set('author', $user_ID );
    	return $query;

    Essentially this checks to see if you are in admin

    Then the critical bit for ACF it looks to see if you are editing a page which is the screen->base === ‘post’ bit. That will return the standard query since the mod to user_ID in the query loses the ACF fields.

    Like I said this works here and I should be grateful if you can let me know if it works for you too.

    By the way I have additional code to change the headings on the list of posts since it shows all and published even though you can’t see them.

    All the best