tags:

views:

44

answers:

2

This first bit works:

                $my_id = 617;
                $post_id_7 = get_post($my_id); 
                $title = $post_id_7->post_excerpt;
                echo $title;

While this second bit doesn't:

                $post_id_7 = get_post(617); 
                $title = $post_id_7->post_excerpt;
                echo $title;

What gives?

+3  A: 

http://codex.wordpress.org/Function_Reference/get_post

You must pass a variable containing an integer (e.g. $id). A literal integer (e.g. 7) will cause a fatal error

Samuel
+1  A: 

yeah what Samuel said.

So if you wrote it:

$post_id_7 = get_post('617');  
$title = $post_id_7->post_excerpt; 
echo $title; 

it should work.

Jamie
That would just pass a string. The get_post parameter is passed by reference so you MUST pass a variable and not a literal value.
Samuel