Count views without get_post_meta

If you provided full code, issue is probably in this line: $wpdb->prepare(“INSERT INTO ‘myprefix_posts_views’ (postid, ip, device) VALUES (%d, %s, %s) ON DUPLICATE KEY UPDATE create_at=VALUES(create_at)”, $postID, $_SERVER[‘REMOTE_ADDR’], $_SERVER[‘HTTP_USER_AGENT’]); Because into column postid you are trying to put variable $postID, when you didn’t declare it anywhere. This column is NOT NULL, so probably you have … Read more

error establishing database for all wordpress on same instance

First of all, you should check the DB Configuration at wp-config.php, is the name and the db user+pw correct? Does the DB User have all the necessary permissions to the DB? Is the DB Server running at all? You find more info how wp config should like over here: https://help.dreamhost.com/hc/en-us/articles/214693268-WordPress-wp-config-php-overview

Naming conventions for database tables

There’s only one naming convention to remember, the WP table prefix. If you don’t want to use it you can do whatever you want. WordPress only cares about its own tables, you can create any other tables you want. Keep in mind though that the WordPress table prefix isn’t always wp_, and it changes for … Read more

Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder

There are 2 places that could have issues: Your first wpdb::prepare() here: // Prepare and execute the count query $count_query = $wpdb->prepare( $count_sql, …$query_params ); The initial value you set for $count_sql is “SELECT COUNT(*) FROM $table_name WHERE 1=1”, and if $filters doesn’t have any key matching your switch, the value of $count_sql will remain … Read more

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