I have been staring at this for the last hour and can't seem to understand why this is not working. The code below gets the info from the table, which is in an array (example below the code).
$post_id = 228;
$content_post = get_post($post_id);
$content = $content_post->post_content;
global $wpdb;
$results =$wpdb->get_results("SELECT * FROM wp_article_hyperlinks");
foreach ($results as $result){
// $url = $result["url"];
// $title = $result["title"];
echo '<pre>';
var_dump($result["title"]);
echo '</pre>';
}
}
I am trying to get the title value, but the above just dumps a blank screen. When I run a foreach with a key and value all I get is int or NULL when I use the key.
object(stdClass)#717 (4) {
["ID"]=>
string(1) "1"
["time"]=>
string(19) "2018-08-22 12:30:29"
["title"]=>
string(15) "gluteus maximus"
["url"]=>
string(86) "/wp-content/blahblah"
}
I have compared it to other code/posts on SO and W3Schools and I'm pretty sure that whatever I'm missing is pretty basic but I can't see it.
echo $result->title;it's an object not an array.