Title: WP_REST_Template_Revisions_Controller::prepare_links
Published: November 8, 2023
Last modified: May 20, 2026

---

# WP_REST_Template_Revisions_Controller::prepare_links( WP_Block_Template $template ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#wp--skip-link--target)

Prepares links for the request.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#parameters)󠁿

 `$template`[WP_Block_Template](https://developer.wordpress.org/reference/classes/wp_block_template/)
required

Template.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#return)󠁿

 array Links for the given post.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#source)󠁿

    ```php
    protected function prepare_links( $template ) {
    	$links = array(
    		'self'   => array(
    			'href' => rest_url( sprintf( '/%s/%s/%s/%s/%d', $this->namespace, $this->parent_base, $template->id, $this->rest_base, $template->wp_id ) ),
    		),
    		'parent' => array(
    			'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->parent_base, $template->id ) ),
    		),
    	);

    	return $links;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php#L275)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php#L275-L286)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#related)󠁿

| Uses | Description | 
| [rest_url()](https://developer.wordpress.org/reference/functions/rest_url/)`wp-includes/rest-api.php` |

Retrieves the URL to a REST endpoint.

  |

| Used by | Description | 
| [WP_REST_Template_Revisions_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php` |

Prepares the item for the REST response.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_template_revisions_controller/prepare_links/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.4.0](https://developer.wordpress.org/reference/since/6.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_template_revisions_controller%2Fprepare_links%2F)
before being able to contribute a note or feedback.