wpdb select from using array as search parameters

Pass your information through prepare as in this example from the Codex: $metakey = “Harriet’s Adages”; $metavalue = “WordPress’ database interface is like Sunday Morning: Easy.”; $wpdb->query( $wpdb->prepare( ” INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) “, array( 10, $metakey, $metavalue ) ) ); Your array should have … Read more

Can’t print out returned value

Correct way to get the ratings for individual authors. This is for the author.php page. If you want to display it elsewhere on your site, for example to show the number of likes for the currently logged in user, then use get_current_user_id( ‘ID’ ); in place of get_the_author_meta. <?php function author_rating_total() { $user_id = get_the_author_meta( … Read more

Widget checkbox array empty on update function

I suspect this is mostly happening because down towards the bottom, you’ve got an input that’s not using $this->get_field_name() (the first of the two checkbox inputs). Try using $this->get_field_name() as you did in the “then” clause of that section of code and it should be OK. Not much else wrong that I can see.

Adapting a php array to WordPress

Here is some code; you need to see that the $current_user variable is actually an object and not an array ( USE $current_user->user_login AND NOT $current_user[‘user_login’] ). I also added a simple check to make sure the user is logged in. // Set the Query POST parameters – array $query_vals = array( ‘api_username’ => ‘api-username-goes-here’, … Read more

Get current user array with post string

Your code has a lot of errors. For example, inside you should define the global $current_user, not outside. Other error, you use $query_vals variable outside the function where that variable is not defined. Anyway, I would use the function wp_get_current_user() which have not to be called before init action hook. For example, if you are … Read more

Pulling posts tagged with similar title name

First of all, don’t use query_posts Form Codex: Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of … Read more

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