| | 4637 | |
| | 4638 | /** |
| | 4639 | * Retrieve content from the specified post. |
| | 4640 | * |
| | 4641 | * get_the_content() assumes setup_postdata() has previously been called. |
| | 4642 | * In order to call get_the_content() without side-effects you must first |
| | 4643 | * collect up the values of the global variables assigned in setup_postdata() |
| | 4644 | * and afterwards restore those global variables. |
| | 4645 | * |
| | 4646 | * @since 3.1.0 |
| | 4647 | * |
| | 4648 | * @uses save_postdata(), setup_postdata(), restore_postdata(), get_the_content() |
| | 4649 | * |
| | 4650 | * @param object $post Post data. |
| | 4651 | * @param string $more_link_text Optional. Content for when there is more text. |
| | 4652 | * @param string $stripteaser Optional. Teaser content before the more text. |
| | 4653 | * @return string The Post's content |
| | 4654 | */ |
| | 4655 | function get_post_content($post, $more_link_text = null, $stripteaser = 0) { |
| | 4656 | $save = save_postdata(); |
| | 4657 | setup_postdata($post); |
| | 4658 | $the_content = get_the_content($more_link_text,$stripteaser); |
| | 4659 | restore_postdata($save); |
| | 4660 | return $the_content; |
| | 4661 | } |
| | 4662 | /** |
| | 4663 | * Retrieve the excerpt from the specified post. |
| | 4664 | * |
| | 4665 | * get_the_excerpt() assumes setup_postdata() has previously been called. |
| | 4666 | * In order to call get_the_excerpt() without side-effects you must first |
| | 4667 | * collect up the values of the global variables assigned in setup_postdata() |
| | 4668 | * and afterwards restore those global variables. |
| | 4669 | * |
| | 4670 | * @since 3.1.0 |
| | 4671 | * |
| | 4672 | * @uses save_postdata(), setup_postdata(), restore_postdata(), get_the_excerpt() |
| | 4673 | * |
| | 4674 | * @param object $post Post data. |
| | 4675 | * @return string The Post's excerpt |
| | 4676 | */ |
| | 4677 | function get_post_excerpt($post) { |
| | 4678 | $save = save_postdata(); |
| | 4679 | setup_postdata($post); |
| | 4680 | $the_excerpt = get_the_excerpt(); |
| | 4681 | restore_postdata($save); |
| | 4682 | return $the_excerpt; |
| | 4683 | } |