Alternative functions for mysql_free_result and mysql_ping in wordpress functions

You have the following methods of the $wpdb object: $wpdb->flush() that contains a call to mysqli_free_result() or mysql_free_result() if not supported. $wpdb->check_connection() that contains a call to mysqli_ping() or mysql_ping() if not supported. You can of course use all your PHP functions in WordPress. Here’s an example based on the \wpdb class itself: // Use … Read more

Post Views / Hit Counter Problem?

Use the following functionto set views manually function setPostViewsManually($postID, $viewCount) { $count_key = ‘post_views_count’; $count = get_post_meta($postID, $count_key, true); update_post_meta($postID, $count_key, $viewCount); } You can run this code by <?php setPostViewsManually(get_the_ID(), 1234); ?> The above code will set the view to ‘1234’ for the current post. Run this function carefully else your new views will … Read more

Problem in using wpdb

This error: Fatal error: Call to a member function insert() on a non-object Means that $wpdb isn’t instantiated so you are running your code too early or out of WordPress context– for example, in an exterior PHP file accessed directly, which is what I suspect (Poorly conceived AJAX request perhaps?). As mentioned, the code has … Read more

multiple wordpress installation with shared usertable on an different database

After writing those two lines in wp-config.php, your users data will be shared between both installations, but both installations will also need to have the same cookie parameters, so in wp-config.php file of your second installation, modify the COOKIE_DOMAIN like this: define(‘COOKIE_DOMAIN’, ‘.{yoursite.com}’); //replace with URL of first site define(‘COOKIEPATH’, “https://wordpress.stackexchange.com/”);

Remove empty rows from the database

I’d imagine those rows with empty content are more often then not revisions rather than trashed posts. To make sure you don’t delete stuff you want to keep I suggest you add the post_status to your SQL, using trash and auto-draft as value – the latter are the revisions. Btw the table column is called … Read more

How to add an external php page with wordpress?

Firstly your question shows no research or effort whatsoever. Also it isn’t elaborated efficiently. From what I gather you want a page with some code in wordpress. There are multiple ways to do it. Easiest way would be to create a new page template in your theme file. Go to your active theme folder and … Read more