Getting Trying to get property * of non-object when using get_results in WordPre
-
I have two tables that have a one-to-one relationship. one of them is wp_posts and wp_books Now I want to get a post that related to a specif book with this code:
function column_default($item, $column_name) { global $wpdb; switch ($column_name) { case 'post': $post_query = "SELECT * FROM $wpdb->posts WHERE id = {$item->post_id} AND post_type='books' LIMIT 1 "; $post = $wpdb->get_results($post_query, OBJECT); return $post->post_title; default: return $item; } }But I get this error:
Trying to get property ‘post_title’ of non-object
What’s wrong? How can I fix this?
-
I don’t see any WordPress.com sites under your account here.
What is the URL of the site with the problem?
NOTE: We can only assist with websites hosted here at WordPress.com. If you’re using the WordPress software, but hosted elsewhere, you will need to reach out to your hosting provider or the WordPress.org community for guidance: https://wordpress.org/support/
-
Site URL is: https://www.sipotek.net
I posted the same question there for the last 2 days but did not get any answer so I ask the question here.
-
Your site is not hosted with WordPress.com. It is a site using the open-source WordPress software (from WordPress.org) but hosted elsewhere.
Because WordPress.com and WordPress.org are two entirely separate entities, we cannot access files or data for sites that are hosted elsewhere, so WordPress.com staff can only assist with sites that are hosted on our servers. You can find more information here about the differences between WordPress.org software and WordPress.com: https://wordpress.com/support/com-vs-org/
https://wordpress.org/support/ is a great resource for sites using the open source WordPress.org software, and you can find support for that at: https://wordpress.org/support/forums/
Your hosting provider’s support team may also be able to assist.
- The topic ‘Getting Trying to get property * of non-object when using get_results in WordPre’ is closed to new replies.