get_attached_file

Definition:
function get_attached_file( $attachment_id, $unfiltered = false ) {}

Retrieve attached file path based on attachment ID.
You can optionally send it through the ‘get_attached_file’ filter, but by default it will just return the file path unfiltered.

Parameters

  • int $attachment_id: Attachment ID.
  • bool $unfiltered: Whether to apply filters.

Return values

returns:The file path to the attached file.

Defined filters

  • get_attached_file
    apply_filters( 'get_attached_file', $file, $attachment_id )

Source code

function get_attached_file( $attachment_id, $unfiltered = false ) {

	$file = get_post_meta( $attachment_id, '_wp_attached_file', true );

	// If the file is relative, prepend upload dir

	if ( 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) )

		$file = $uploads['basedir'] . "/$file";

	if ( $unfiltered )

		return $file;

	return apply_filters( 'get_attached_file', $file, $attachment_id );

}

1150

get_archive_template

Definition:
function get_archive_template() {}

Retrieve path of archive template in current or parent template.

Source code

function get_archive_template() {

	$post_type = get_query_var( 'post_type' );



	$templates = array();



	if ( $post_type )

		$templates[] = "archive-{$post_type}.php";

1148

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

get_archives

Definition:
function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {}

Parameters

  • string $type
  • string $limit
  • string $format
  • string $before
  • string $after
  • bool $show_post_count

Source code

function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {

	_deprecated_function( __FUNCTION__, '2.1', 'wp_get_archives()' );

	$args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count');

	return wp_get_archives($args);

}

1144

get_approved_comments

Definition:
function get_approved_comments($post_id) {}

Retrieve the approved comments for post $post_id.

Parameters

  • int $post_id: The ID of the post

Return values

returns:The approved comments

Source code

function get_approved_comments($post_id) {

	global $wpdb;

	return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id));

}

1142