Anyone got any clues please?
[php]
[/php]
The echo statements as well as the commented out code are for testing and showing no results.
Anyone got any clues please?
[php]
[/php]
The echo statements as well as the commented out code are for testing and showing no results.
Try doing this in you code, so we can see the SQL that is being executed. Once you get the SQL run it directly in your database and see if you get results
[php]echo “SELECT * FROM $wpdb->posts WHERE post_type=‘name_profile’”[/php]
The query runs fine in phpmyadmin and returns the 9 rows that I expect.
I just can’t get it to work on the live site from a php page.
Did you try wrapping it in curly braces?
[php]$result = $wpdb->get_results(“SELECT * FROM {$wpdb->posts} WHERE post_type=‘name_profile’”);[/php]
I have and still no results from the query.
Just Curious try this…
[php]$result = $wpdb->get_results("SELECT * FROM " . $wpdb->base_prefix . “posts WHERE post_type=‘name_profile’”);[/php]
Or put the table name in directly… Assuming your prefix is wp_
[php]$result = $wpdb->get_results(“SELECT * FROM wp_posts WHERE post_type=‘name_profile’”);[/php]
and echo this, curious what it shows you.
[php]echo $wpdb->posts[/php]
Thanks for your suggestions, but I was getting nowhere. >:(
I gave up in the end and just coded a stand alone page with mysqli rather that Wordpress db commands and it worked perfectly. As this is a one off exercise this will do.
Yeah, wordpress is PITA