Skip to content

mastodon_api_public_timeline

github-actions[bot] edited this page Jul 24, 2026 · 31 revisions

Modify the public timelines data returned for /api/timelines/(public) requests.

Example

add_filter( 'mastodon_api_public_timeline', function( $statuses, $request ) {
    $args = array( 'post_status' => 'publish' );
    $posts = get_posts( $args );
    $statuses = array();
    foreach ( $posts as $post ) {
        $statuses[] = apply_filters( 'mastodon_api_status', null, $post->ID, array() );
    }
    return new WP_REST_Response( array_filter( $statuses ) );
}, 10, 2 );

Parameters

  • WP_REST_Response|null $statuses The statuses data.
  • WP_REST_Request $request The request object.

Returns

WP_REST_Response The modified statuses data.

Files

\apply_filters( 'mastodon_api_public_timeline', null, $request )

Hooks

Clone this wiki locally