Collect all events in one year

OK, your events are already sorted by date, so all you have to do is to ignore header, previous event had the same year. Let’s also try to avoid all that spaghetti code, you’ve posted in question: <?php $previous_year = false; while ( $myrow = mysqli_fetch_array($result) ) : $event_datetime = strtotime($myrow[‘event_date’]); ?> <?php if ( … Read more

SQL – Shorter way to query user and usermeta data

I was just trying out the wp_get_users() function and I think that’s a much cleaner way to get the user data in a table. I can simply do something like this: $users = get_users(‘role=um_student’); foreach ( $users as $user ) { echo “<tr>”; echo “<td>$user->ID</td>”; echo “<td>$user->user_login</td>”; echo “<td>$user->first_name</td>”; echo “<td>$user->middle_name</td>”; echo “<td>$user->last_name</td>”; echo “<td>$user->university_program</td>”; … Read more

how to SELECT meta values that are not null?

I founded myself my searching: $sql = $wpdb->prepare( ” SELECT meta_value FROM {$wpdb->prefix}commentmeta INNER JOIN {$wpdb->prefix}comments ON {$wpdb->prefix}commentmeta.comment_id = {$wpdb->prefix}comments.comment_ID WHERE comment_post_ID = %d AND meta_key = ‘rating’ AND meta_value IS NOT NULL AND meta_value <> ” “, get_the_ID() ); $results = $wpdb->get_results( $sql );

What steps do I need to take to install a local copy of a live website?

wp-cli makes use of your wp-config.php credentials to connect to the db, so the fact that you are getting the install screen, and not getting any errors (I assume) when running wp-cli commands says that you seem to have it configured correctly. My only thought would be that your $table_prefix value doesn’t match the tables … Read more

WPDB SQL query SELECT from category

If you are find products by specified category. Please find below code : $results = $wpdb->get_col( ” SELECT p.ID FROM {$wpdb->prefix}posts as p INNER JOIN {$wpdb->prefix}postmeta as pm ON p.ID = pm.post_id LEFT JOIN {$wpdb->prefix}term_relationships ON ({$wpdb->prefix}posts.ID = {$wpdb->prefix}term_relationships.object_id) WHERE p.post_type LIKE ‘product’ AND p.post_status LIKE ‘publish’ AND pm.meta_key LIKE ‘_stock_status’ AND pm.meta_value LIKE ‘instock’ … Read more

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