get_archives_link

Definition:
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {}

Retrieve archive link content based on predefined or custom code.
The format can be one of four styles. The ‘link’ for head element, ‘option’ for use in the select element, ‘html’ for use in list (either ol or ul HTML elements). Custom content is also supported using the before and after parameters.

Parameters

  • string $url: URL to archive.
  • string $text: Archive text description.
  • string $format: Optional, default is ‘html’. Can be ‘link’, ‘option’, ‘html’, or custom.
  • string $before: Optional.
  • string $after: Optional.

Return values

returns:HTML link content for archive.

Defined filters

  • get_archives_link
    apply_filters( 'get_archives_link', $link_html )

Source code

function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {

	$text = wptexturize($text);

	$title_text = esc_attr($text);

	$url = esc_url($url);



	if ('link' == $format)

		$link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";

	elseif ('option' == $format)

		$link_html = "\t<option value='$url'>$before $text $after</option>\n";

	elseif ('html' == $format)

		$link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";

	else // custom

		$link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";



	$link_html = apply_filters( 'get_archives_link', $link_html );



	return $link_html;

}

1146

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: