I’m trying to get a wordpress excerpt from a page to appear in a styled area of my footer. I currently have the following, which gives me the title and all of the content:
<?php
$page_id = 2;
$page_data = get_page( $page_id );
$content = $page_data->post_content;
$title = $page_data->post_title;
echo '<h3>'. $page_data->post_title .'</h3>';
echo '<p>'. $page_data->post_content .'</p>'; ?>
I’ve tried various combinations of post_excerpt instead of post_content, and have tried emulating and editing the example here: http://codex.wordpress.org/Function_Reference/get_page but am not having any luck. A few times I’ve tried examples from other people, but there has been no content at all.
Could this be because I’m trying to get it to display outside of the loop, or have I just not hit the right combination yet?
Thanks.
Why don’t you just limit the string using substr()?
something to that effect
at that rate, you don’t need to try and find the true variable of the excerpt, and you can control the length, and whether or not it has ellipses at the end, etc.
Also, if you NEED to find the excerpt variables, you could just do a
var_dump($page_data), and see what returns the value you need, no?EDIT:
you could try adding a manual excerpt to the pages using a function like this in functions.php
EDIT on an EDIT:
So I just dug a little deeper, and this little guy right here might help you out. Drop this in your functions.php file (source)