wpfts_se_titlelink (Filter)
The wpfts_se_titlelink
filter in WP Fast Total Search allows developers to modify the link used for the post title in search results when the Smart Excerpts option is enabled. This provides the ability to change the URL that the title links to, depending on the post type, its status, or other parameters.
When to Use
This filter is useful if you need to:
- Change the target page for links in post titles in search results. For example, you can configure links to lead to different pages for different post types.
- Add GET parameters to links.
Arguments
$r1
(array): An array of data containing information about the link. Includes the following keys:is_demo
(bool): A flag for demo mode.is_attachment
(bool): A flag indicating whether the post is an attachment.is_title_direct_link
(bool): A flag indicating whether the link should directly lead to the attachment file (for attachments).link
(string): The URL of the link.
$post
(array): An array of post data.
Return Value
$r1
(array): The modified array of link data. Changes should be made to thelink
key.
Example (Adding a GET Parameter to the Link)
add_filter( 'wpfts_se_titlelink', 'add_get_parameter_to_title_link', 10, 2 );
function add_get_parameter_to_title_link( $r1, $post ) {
$r1['link'] = add_query_arg( 'my_param', 'my_value', $r1['link'] );
return $r1;
}
Example (Modifying the Link for Attachments)
add_filter('wpfts_se_titlelink', 'modify_attachment_link', 10, 2);
function modify_attachment_link($r1, $post) {
if ($r1['is_attachment']) {
$r1['link'] = home_url('/my-custom-attachment-page/?attachment_id=' . $post['ID']);
}
return $r1;
}
Important Notes
- The
wpfts_se_titlelink
filter is only called when using Smart Excerpts. - Changes made to the link will be reflected in the search results.
This filter gives developers the ability to flexibly customize links in post titles in WP Fast Total Search results.