Tag Info

New answers tagged

0

In your query, you'll see: AND .ID IN (SELECT 'post_id' FROM 'lat_lng_post' WHERE (. The actual posts table name is missing from the query. The problem is you are missing the $ from your declaration of wpdb. global $wpdb.


0

Not sure about DB connection but there seems some syntax issue. lat and lng have been used unlike PHP variables at some places in your code. I believe, they should have been $lat and $lng respectively instead.


0

First, this line if ( 'location' != $_POST['festival-event'] ) should be if ( 'festival-event' != $_POST['post_type'] )


0

As David pointed out, wpdb::query() does not allow multiple calls. So yes, it is because of having the "SET @newnum = 0;" before your actual query. This kind of query is simply not possible as the backend prevents that in order to protect against SQL injection attacks. Besides of that, the technique I described in my blog serves a different use case which ...


0

Here is one approach: $myrows = $wpdb->get_results( "SELECT first_name, surname, role, email, country, bio FROM members" ); foreach ( $myrows as $row ) { $first_name = $row->first_name; if ( ! empty( $row->bio ) ) { $first_name = '<a href="#">' . $first_name . '</a><div class="bio" style="display: none;">' . ...


1

The problem is that you can't use the value for the LIKE comparison as you've mentioned. The generated SQL will look something along the lines of: AND CAST(wp_usermeta.meta_value AS CHAR) LIKE '%B%' which means that the query is set to look for every occurrence of letter B in our case. Of course this is not what you want, what you would need is something ...


1

I peeked into the WP_User_Query class and it supports a WP_Date_Query query on the user registration date. So we could use: $query = new WP_User_Query( $args ); or simply: $users = get_users( $args ); where: $args = [ 'fields' => 'ID', 'number' => 8, 'date_query' => [ [ 'before' => '359 days ago midnight' ], ...


0

Did you try including wp-load.php instead of wp-blog-header.php? wp-load.php will load the full WP environment, and set up $wpdb, which you would need before using WP_Query. Just a thought. Otherwise, you can also look at wp-cron.php (if you have not done so yet), and see what it does.


0

Use $wpdb->get_results("SELECT *, (DATEDIFF(NOW(),user_registered)) AS daydiff FROM {$wpdb->users} WHERE 'daydiff' = 360");


0

This part require('./wp-blog-header.php'); is all kinds of bad idea. And if your file is indeed in plugin folder then header isn't even in that location. Custom loads of WordPress core are brittle and the technique is typically only justifiable for performance reasons. It would be better to structure your endpoint via creating actual rewrite endpoint, or ...



Top 50 recent answers are included