wppaste
WordPress

get_boundary_post_rel_link( string $title = '%title', bool $in_same_cat = false, string $excluded_categories = '', bool $start = true ): string

Since
2.8.0
Source
wp-includes/deprecated.php:2690
Get boundary post relational link.

Description

Can either be start or end post relational link.

Compatibility

Deprecated in WordPress 3.3.0. Kept for back-compatibility; avoid it in new code.

WordPress
since 2.8.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Parameters

$titlestringoptional
Link title format. Default '%title'.Default: '%title'
$in_same_catbooloptional
Whether link should be in a same category.
Default false.Default: false
$excluded_categoriesstringoptional
Excluded categories IDs. Default empty.Default: ''
$startbooloptional
Whether to display link to first or last post.
Default true.Default: true

Return value

string

Performance profile

How much work a call to get_boundary_post_rel_link() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reaches the database via get_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
17–76

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 83.

Plugin surface
2 hooks

Third-party callbacks on 'the_title', '{$boundary}_post_rel_link' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()called directly
  • querycontent queryget_post()one call below get_boundary_post_rel_link()
  • cacheobject cachewp_cache_get()one call below get_boundary_post_rel_link()
  • serializeserialisationmaybe_unserialize()one call below get_boundary_post_rel_link()

Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 3 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost get_boundary_post_rel_link() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
empty($posts)17_deprecated_function(), get_boundary_post()
!empty($posts) && !empty($post)66–68_deprecated_function(), get_boundary_post(), get_option(), mysql2date(), apply_filters(), esc_attr(), get_permalink(), apply_filters()
!empty($posts) && empty($post)73–76_deprecated_function(), get_boundary_post(), __(), get_option(), mysql2date(), apply_filters(), esc_attr(), get_permalink(), apply_filters()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev8117–7552 fewer instructions than PHP 8.5
8.58317–765
8.48317–7656 fewer instructions than PHP 8.3
8.38917–825
8.28917–825
8.18917–825
7.48917–825

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 2

2 hooks fire while get_boundary_post_rel_link() runs, in this order:

  1. apply_filters( the_title )filterline 2709 (+19 into the body)

    Filters the post title.

  2. apply_filters( {$boundary}_post_rel_link )filterline 2716 (+26 into the body)

Uses · 8

Used by · 1

Source code

function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {	_deprecated_function( __FUNCTION__, '3.3.0' ); 	$posts = get_boundary_post($in_same_cat, $excluded_categories, $start);	// If there is no post, stop.	if ( empty($posts) )		return; 	// Even though we limited get_posts() to return only 1 item it still returns an array of objects.	$post = $posts[0]; 	if ( empty($post->post_title) )		$post->post_title = $start ? __('First Post') : __('Last Post'); 	$date = mysql2date(get_option('date_format'), $post->post_date); 	$title = str_replace('%title', $post->post_title, $title);	$title = str_replace('%date', $date, $title);	/** This filter is documented in wp-includes/post-template.php */	$title = apply_filters('the_title', $title, $post->ID); 	$link = $start ? "<link rel='start' title='" : "<link rel='end' title='";	$link .= esc_attr($title);	$link .= "' href='" . get_permalink($post) . "' />\n"; 	$boundary = $start ? 'start' : 'end';	return apply_filters( "{$boundary}_post_rel_link", $link );}

Changelog

Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

3.3.0
Deprecated.from the docblock
2.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/deprecated.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.