Advertisements

setup_postdata

Definition:
function setup_postdata($post) {}

Set up global post data.

Parameters

  • object $post: Post data.

Return values

returns:True when finished.

Defined actions

  • the_post
    do_action_ref_array('the_post', array(&$post));

Source code

function setup_postdata($post) {

	global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;



	$id = (int) $post->ID;



	$authordata = get_userdata($post->post_author);



	$currentday = mysql2date('d.m.y', $post->post_date, false);

	$currentmonth = mysql2date('m', $post->post_date, false);

	$numpages = 1;

	$page = get_query_var('page');

	if ( !$page )

		$page = 1;

	if ( is_single() || is_page() || is_feed() )

		$more = 1;

	$content = $post->post_content;

	if ( strpos( $content, '<!--nextpage-->' ) ) {

		if ( $page > 1 )

			$more = 1;

		$multipage = 1;

		$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);

		$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);

		$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);

		$pages = explode('<!--nextpage-->', $content);

		$numpages = count($pages);

	} else {

		$pages = array( $post->post_content );

		$multipage = 0;

	}



	do_action_ref_array('the_post', array(&$post));



	return true;

}

2837

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: