开发者

Why don't these two wordpress php blocks work out the same?

This first bit works:

                $my_id = 617;
                $post_id_7 = get_post($my_id); 
   开发者_如何学JAVA             $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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜