Filter hook 'preview_post_link'

in WP Core File wp-includes/link-template.php at line 1435

View Source

preview_post_link

Filter Hook
Description
Filters the URL used for a post preview.

Hook Information

File Location wp-includes/link-template.php View on GitHub
Hook Type Filter
Line Number 1435

Hook Parameters

Type Name Description
string $preview_link URL used for the post preview.
WP_Post $post Post object.

Usage Examples

Basic Usage
<?php
// Hook into preview_post_link
add_filter('preview_post_link', 'my_custom_filter', 10, 2);

function my_custom_filter($preview_link, $post) {
    // Your custom filtering logic here
    return $preview_link;
}

Source Code Context

wp-includes/link-template.php:1435 - How this hook is used in WordPress core
<?php
1430  	 * @since 4.0.0 Added the `$post` parameter.
1431  	 *
1432  	 * @param string  $preview_link URL used for the post preview.
1433  	 * @param WP_Post $post         Post object.
1434  	 */
1435  	return apply_filters( 'preview_post_link', $preview_link, $post );
1436  }
1437  
1438  /**
1439   * Retrieves the edit post link for post.
1440   *

PHP Documentation

<?php
/**
	 * Filters the URL used for a post preview.
	 *
	 * @since 2.0.5
	 * @since 4.0.0 Added the `$post` parameter.
	 *
	 * @param string  $preview_link URL used for the post preview.
	 * @param WP_Post $post         Post object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/link-template.php
Related Hooks

Related hooks will be displayed here in future updates.