\WP_Stager_Integration\Event::filter_canonical_url(string $canonical_url, ...$args): string
\WP_Stager_Integration\Event::filter_canonical_url(string $canonical_url, ...$args): stringDescription
Filters the canonical URL to use the correct event permalink structure.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$canonical_url | string | The current canonical URL. |
Returns:
string The filtered canonical URL.
Information
| File | class-event.php line 272 |
|---|
Full Code
/**
* Filters the canonical URL to use the correct event permalink structure.
*
* @param string $canonical_url The current canonical URL.
* @param mixed ...$args Additional arguments (e.g., Yoast SEO presentation object).
*
* @return string The filtered canonical URL.
*/
public static function filter_canonical_url( $canonical_url, ...$args ) {
// Bail if not on a single event page
if ( ! self::is_single_event() ) {
return $canonical_url;
}
// Get event ID
$event_id = self::get_single_event_id();
if ( ! $event_id ) {
return $canonical_url;
}
// Get the correct permalink for this event
$correct_permalink = self::get_permalink( $event_id );
if ( ! $correct_permalink ) {
return $canonical_url;
}
return $correct_permalink;
}💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration
🎁 Limited offer: Use code WELCOME26 to get your first month for free!

