error while loading wordpress post using ID

I am trying to retrieve the content of a wordpress post using its ID:

$loadpost = url_to_postid($actual_link); 
$newpost = get_post($loadpost);
echo '<article id="post-'.$newpost["ID"].'"><h1>'.$newpost["post_title"].'</h1>'.$newpost["post_content"];

$loadpost returns a valid ID but somehow this expression does not work. IE returns:

Fatal error: Cannot use object of type stdClass as array in /hermes/waloraweb046/b428/moo.snippetspacecom/splittemplate/wp-content/themes/split/index.php on line 24

What does this mean?

Thanks for your help guys.

Answers


Because get_post(); by default outputs as an OBJECT

What you want to return is

echo '<article id="post-'.$newpost->ID.'"><h1>'.$newpost->post_title.'</h1>'.$newpost->post_content;

Need Your Help

Vim programmatically save with different file extension

bash vim

I'm writing slim files in Vim and I want them to compile and save as html files when I save. Adding this to my .vimrc makes it happen for files in the current directory:

Find number of months weeks and day from a number

php

Say I have the number 234 edit (in days). How can I find how many months ,weeks and days?