Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post Preview Link Not Filtering As Draft #25228

Closed
TeamDNK opened this issue Sep 11, 2020 · 1 comment
Closed

Post Preview Link Not Filtering As Draft #25228

TeamDNK opened this issue Sep 11, 2020 · 1 comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@TeamDNK
Copy link

TeamDNK commented Sep 11, 2020

Description
We are currently using preview_post_link to customize the preview link for a custom post type that we have registered. The hook works well while the post is in a "publish" state but fails to apply while the post is in draft mode nor is there any hook that I can find that filters the preview link specifically while in draft mode. The filter looks similar to this:

<?php

add_filter( 'preview_post_link', array( $this, 'change_preview_link' ), 10, 2 );

public function change_preview_link( $preview_link, $post ) {
	if ( $post->post_type !== $this->post_type) return $preview_link;

	// ...Parse/construct link
	
	return $preview_link;
}

?>

The behavior I expected was for the preview button to be filtered as a draft, auto-draft, and published. I assumed that I would be specifying any unique logic using $post->post_status to assign conditionally or that there would be a hook specific to the preview link as a draft for example preview_post_link_draft. Any help would be appreciated.

Thank you,

Bula
Chief Technology Officer
The DNK Office


Editor version:

  • WordPress version: 5.5.1
  • Default Block Editor

Desktop (please complete the following information):

  • iOS
  • Safari
  • Version 13.1.2
@youknowriad youknowriad added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Sep 15, 2020
@tellthemachines
Copy link
Contributor

Hi there @TeamDNK ! I'm afraid this is a known issue with no certain timeline to be fixed. You can read more about it in #13998. I'm going to go ahead and close this one as it's essentially a duplicate of #13998, but please feel free to reopen if this doesn't answer your question!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants