preview_post_link

Filters the URL used for a post preview.

Description

apply_filters( 'preview_post_link', (string) $preview_link, (WP_Post) $post ); 

Parameters (2)

0. $preview_link (string)
URL used for the post preview.
1. $post (WP_Post)
Post object.

Usage

To run the hook, copy the example below.
  1. $preview_link = apply_filters( 'preview_post_link', $preview_link, $post ); 
  2.  
  3. if ( !empty( $preview_link ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the preview_post_link callback 
  2. function filter_preview_post_link( $preview_link, $post ) { 
  3. // make filter magic happen here... 
  4. return $preview_link
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'preview_post_link', 'filter_preview_post_link', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'preview_post_link', 'filter_preview_post_link', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/link-template.php  
  1. return apply_filters( 'preview_post_link', $preview_link, $post );