\WP_Stager_Integration\Event::get_permalink(int $event_id): string
\WP_Stager_Integration\Event::get_permalink(int $event_id): stringDescription
Gets the permalink URL for an event.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$event_id | int | The Stager event ID. |
Returns:
string The event permalink URL, or an empty string if event pages are disabled or the event ID is invalid.
Information
| File | class-event.php line 738 |
|---|
Full Code
/**
* Gets the permalink URL for an event.
*
* @param int $event_id The Stager event ID.
*
* @return string The event permalink URL, or an empty string if event pages are disabled or the event ID is invalid.
*/
public static function get_permalink( $event_id ) {
// Type casting
$event_id = (int) $event_id;
// Bail if invalid event ID
if ( ! $event_id ) {
return '';
}
// Get data
$event_pages_enabled = (bool) Options::is_enabled_event_pages();
$permalink_base = (string) (Options::get_event_permalink_base() ?: '');
// Bail if event pages are disabled or no permalink base is set
if ( ! $event_pages_enabled || ! $permalink_base ) {
return '';
}
// Get data
$permalink_structure = (string) (Options::get_event_permalink_structure() ?: '');
// Build permalink URL
$permalink_base = trailingslashit( get_home_url() ) . $permalink_base;
$permalink = trailingslashit( $permalink_base ) . $permalink_structure;
// Parse permalink structure
$permalink_url = (string) self::parse_permalink_structure( $permalink, $event_id );
// Return permalink URL
return trailingslashit( $permalink_url );
}💡 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!

