coresocial_get_term_url

Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

PHP
Definition
apply_filters( "coresocial_get_term_url", $url, $term, $method );
coreSocial 4.0 — core/base/Method.php:165
Arguments
Name
Type
Description
$url
string|WP_Error
Term link returned by get_term_link().
$term
WP_Term
Resolved term object.
$method
Dev4Press\Plugin\coreSocial\Base\Method
Calling sharing method.
Returns
string — Term URL usable by the renderer.

Runs after the term link has been resolved. Preserve the term context when changing its URL.

WordPress can return WP_Error for a term link. The enclosing get_term_url() method declares a string return type, so an unhandled error cannot be returned safely. The example converts that case to an empty string.

Example

add_filter( 'coresocial_get_term_url', function ( $url, $term, $method ) {
    return is_wp_error( $url ) ? '' : remove_query_arg( 'utm_source', $url );
}, 10, 3 );
Rate this reference
0
0
2

You are not allowed to rate this post.

Leave a Comment

0
0
0
0
0
0
0
0
0