\WP_Stager_Integration\Event::filter_event_content(string $content): string

Description

Filters event post content.

Parameters:

ParameterTypeDescription
$content string The post content to filter.

Returns:

string The filtered post content.

Full Code

/**
 * Filters event post content.
 *
 * @param string $content The post content to filter.
 *
 * @return string The filtered post content.
 *
 * @see \WP_Stager_Integration\Event::is_single_event()
 * @see \WP_Stager_Integration\Event::get_single_event_data()
 */
public static function filter_event_content( $content ) {

    // Bail if not on a single event page
    if ( ! self::is_single_event() ) {
        return $content;
    }

    // Get data
    $event = (array) (self::get_single_event_data() ?: array());

    // Get event content
    ob_start();
    \WP_Stager_Integration::include( 'single-event-content', 'template-parts' );
    $event_content = ob_get_clean();

    // Get event ID
    $event_id = (int) ($event[ 'id' ] ?? 0);

    /**
     * Filters the post content on single event pages.
     *
     * @param string    $event_content  The event content HTML.
     * @param int       $event_id       The Stager event ID.
     * @param array     $event          The raw Stager event data.
     *
     * @return string   Must return an HTML string.
     */
    $event_content = (string) (apply_filters( 'wpstagerintegration_content_single_event', $event_content, $event_id, $event ));

    return $event_content;
}

💡 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!