Frontside menu based on custom roles logged in permission

There are at least two ways you can accomplish this: 1. Easy way: simply create two nav menus, one for logged in users, and one for logged out users. Then wherever your theme uses wp_nav_menu() you would simply wrap that output in a conditional to check whether the user is logged in/out and output the … Read more

Geographical proximity query using post_meta

Oh dear, that was extremely obvious – there was a missing closing bracket! Here is the working query. SELECT ID, ( 6371 * acos ( cos ( radians( 35.665833 ) ) * cos( radians( latitude.meta_value ) ) * cos( radians( longitude.meta_value ) – radians( 139.731111 ) ) + sin ( radians(35.665833 ) ) * sin( … Read more

Accessing external database: ERR_INCOMPLETE_CHUNKED_ENCODING

I found the solution by logging into the site FTP, renaming my WP site’s index.php to index.php_, and supplying this code in a new index.php file: <!DOCTYPE html> <html> <body> <?php $servername = “xxx.xxx.xxx.xxx”; $username = “xxxxx”; $password = “xxxxx”; try { $conn = new PDO(“mysql:host=$servername;dbname=xxxxxx”, $username, $password); // set the PDO error mode to … Read more

get_row returns empty when data exists

You have several things going on there and I may not be able to sort them all out. Unless $wpdb->cf7dbplugin_submits has been added to the $wpdb object your query won’t work. You will need something like {$wpdb->prefix}cf7dbplugin_submits instead but I can’t really guess at the right value. You don’t need to swap in 9999. That … Read more

Why is an empty result an error? ( $wpdb->get_row )

There isn’t an error. The square brackets are empty– aka “no error”. Put a spurious comma in the SQL and you will see what I mean. But your SQL is wildly complicated for you are doing. That is entirely equivalent to SELECT * FROM $table ORDER BY id DESC LIMIT 1 Though, I notice you … Read more

Depreciated Call -> Function wpdb::escape()

prepare works a bit differently than escape in that it works on whole strings and manages quoting as well. $pat = “UPDATE {$wpdb->posts} SET %s = %s WHERE ID = %d”; $qry = $wpdb->prepare( $pat, $key, $visibility, $post_id ); $wpdb->query($qry); You do not need to swap in the table name at all, and with prepare … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)