Title: post excerpt
Last modified: August 19, 2016

---

# post excerpt

 *  [kikko088](https://wordpress.org/support/users/kikko088/)
 * (@kikko088)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/)
 * i try to follow this wordpress wiki [http://codex.wordpress.org/Function_Reference/get_page](http://codex.wordpress.org/Function_Reference/get_page)
   
   for put on my home page the excerpt of some post, with this code i put on my 
   home page the content
 * <?php
    $page_id = 424; $page_data = get_page( $page_id ); $content = $page_data-
   >post_content; $title = $page_data->post_title; echo $page_data->post_content;?
   >
 * then with (theorically) I put the excerpt on the home page, but nothing,
 * <?php
    $page_id = 424; $page_data = get_page( $page_id ); $content = $page_data-
   >post_content; $title = $page_data->post_title; $excerpt = $page_data->post_excerpt;
   echo $page_data->post_excerpt; ?>
 * where is the mistake?the function is in the codex so it should go 🙁
 * kikko088

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1606822)
 * Does the page have an excerpt entered into the excerpt field?
 * If there’s nothing in the excerpt field for that page, you’ll see just that, 
   nothing!.. 🙂
 * You could use something like this instead..
 *     ```
       <?php global $post; $myposts = get_posts('post_type=page&include=424'); ?>
       <?php foreach( $myposts as $post ) : setup_postdata( $post ); ?>
           <?php the_excerpt(); ?>
       <?php endforeach; wp_reset_query(); ?>
       ```
   
 * [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 * Using `get_posts()` and `setup_postdata()` should allow the use of `the_excerpt()`
   which will return content even if you’ve not used the excerpt field.. 😉
 * **NOTE: **Despite the name, `get_posts()` can return any post_type, not just 
   posts.. (and it supports more parameters then the get_page eqivalent).
 *  Thread Starter [kikko088](https://wordpress.org/support/users/kikko088/)
 * (@kikko088)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1606902)
 * yes i create an excerpt field with some word but nothing, your code is perfect,
   now I have to add the possibility to have random subpage of a page.
    I don’t 
   know that get_post return also page, i think that return only posts, thank you
   very much!
 * excuse me for my bad english 🙂
    kikko088
 *  Thread Starter [kikko088](https://wordpress.org/support/users/kikko088/)
 * (@kikko088)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1606909)
 * now i put on the code the parent and random,but i have only a question, to have
   the link to complete post instead the “[…]” what I have to do?
    thank you very
   much.
 * kikko088
 *  [Kapil Chugh](https://wordpress.org/support/users/kapilchugh/)
 * (@kapilchugh)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1606982)
 * add this code in your functions.php
 *     ```
       add_filter('wp_trim_excerpt', custom_excerpt);
       function custom_excerpt($text) {
         $text = str_replace('[...]', '<a href="' . get_permalink() .'">..complete post</a>', $text);
         return $text;
       }
       ```
   
 *  Thread Starter [kikko088](https://wordpress.org/support/users/kikko088/)
 * (@kikko088)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1606984)
 * thank you!
 *  [raskull](https://wordpress.org/support/users/raskull/)
 * (@raskull)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1607031)
 * In WP 2.9+ you can use excerpt_more instead of wp_trim_excerpt:
 *     ```
       add_filter('excerpt_more', 'custom_excerpt');
       function custom_excerpt($custom) {
       	return '<a href="' . get_permalink() .'">..complete post</a>';
       }
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘post excerpt’ is closed to new replies.

## Tags

 * [excerpt](https://wordpress.org/support/topic-tag/excerpt/)
 * [page](https://wordpress.org/support/topic-tag/page/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 6 replies
 * 4 participants
 * Last reply from: [raskull](https://wordpress.org/support/users/raskull/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/post-excerpt/#post-1607031)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
