I used the Query Monitor plugin to find slow query on my WordPress site. The below-mentioned WP_Query->get_posts() takes about 0.3446 query time out of the total Database Query time of 0.3976. SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND wp_posts.ID NOT IN (203598) AND ( wp_term_relationships.term_taxonomy_id IN (17) OR wp_term_relationships.term_taxonomy_id IN (11652,20693,21952,23971,24907,24908,25928) ) AND wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 6 I'm guessing it …
I have custom table like this: useraw 1. id (Primary*) 2. user_ip 3. post_id 4. time I am inserting data in the table using $wpdb->insert($table_name , array('user_ip' => $user_ip, 'post_id' => $postID, 'time' => $visittime),array('%s','%d', '%d') ); There are four rows I inserted using this code: id : 245 user_ip : 245.346.234.22 post_id : 24434 time : 255464 id : 345 user_ip : 245.346.234.22 post_id : 23456 time : 23467 id : 567 user_ip : 245.346.234.22 post_id : 57436 time …
I have this folder here that contains the multiple sql files and I want to convert them to Gzip using 7Zip. You can only see 10 files but there are 254 files since it is a large database. I tried the following command for /f %%X in (*.sql) do "c:\Program Files\7-Zip\7z.exe" a -tgzip "%%X.zip" "%%X" but command prompt says "The system cannot find the file *.sql." Even the command with no extension such as (*.) says the same thing that …
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) …
The existing WooCommerce orders table in the wp-admin dashboard orders the results by the date the order was made, but I want to modify the query to order by date and also by the shipping method of the order, where same-day delivery takes priority over standard delivery, etc. I'm aware I can use the wc_get_orders() function to get all the orders myself and change the query however I like, but I need this new ordering system to work on the …
Is there any way to speed this query? Noob here. SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (9,11) ) AND wp_term_relationships.term_taxonomy_id IN (18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,151,152,169,170,171,172,173,174,175,177,178,179,181,182,183,184,185,187,191,192,195,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,721,724,726,728,729,742,743,744,747,750,758,759,760,781) ) AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY RAND() LIMIT 0, 6 I'm using query monitor and this is from homepage of site. I think this is reading from Menu, because there …
I'm using Cryto Plugin and want to get coin price data from plugin db. For easy practice, I'm trying to get BTC data. <?php function get_coin_price($coin_symbol) { global $wpdb; $coin_price = $wpdb->get_var($wpdb->prepare("SELECT price FROM {$wpdb->prefix}cmc_coins_v2 WHERE symbol = '%s'", $coin_symbol)); return $coin_price; }?> And if I want to get BTC price, I use this code. <?php get_coin_price(BTC); ?> However I'm getting this error "Use of undefined constant BTC - assumed 'BTC' (this will throw an Error in a future version …
Trying to install wordpress without xamp on my local machine. Version info: Wordpress: 5.2.3 PHP: 7.3.9 Apache: 2.4.41 When accessing this url -http://localhost:8080/wordpress/wp-admin/install.php, I see the following in wordpress logs: [16-Sep-2019 18:47:34 UTC] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\apps\httpd-2.4.41-win64- VS16\Apache24\htdocs\wordpress\wp-includes\wp-db.php:1643 I tried the solutions available online but I still see the error. Solutions I tried so far: Add the following to my wp-config.php: define( 'WP_USE_EXT_MYSQL', true); Added following to php.ini: extension_dir = "ext" extension=php_mysqli.dll …
Is it possible to create a table with the wpdb::prepare function? I read the documentation and tried to find examples but there where none that helped me. Even creating a table with prepare doesn't give me any useful examples on Google. Currently I'm creating my table like this: public function createTableFromFields( $tablename, $fields ) { // $wpdb = $this->db; $tablename = $wpdb->prefix . $tablename; $sql = 'CREATE TABLE IF NOT EXISTS ' . $tablename . ' (id INT(6) UNSIGNED AUTO_INCREMENT …
I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL table, SELECT the rows which match the search criteria and dispense those values into a table on the same page. Unfortunately, I have been unsuccessful thus far. Per the example I followed, three components are necessary to query a SQL table from …
I have 5,000 regular posts, 6,000 posts in one post type and 2,000 posts in another post type. Needless to say, that has made the wp_posts table quite large. Not to mention, I have custom taxonomies set up to mimic the post types so for every Company A entered into Company post type, there is Company A, I manually entered Company A into Company taxonomy. That way, when I do a regular post about Company A, I can effectively tag …
I have my site hosted with NetworkSolution, and they have a sql database size limit of 300MB. IF the size exceeds this limit we cannot access the wordpress admin dashboard. So currently its showing 441MB, and its overlimit. And they are force me to upgrade the database size to 1GB for 120$/yearly. But previously I had all tables size totaling to 45MB, but the database size was 321MB, and I had to request them to grant me access, so they …
I'm trying not to save empty data (null) while using add_meta_box function. My code is /** * Register meta boxes. */ function hcf_register_meta_boxes() { add_meta_box( 'hcf-1', __( 'Hello Custom Field', 'hcf' ), 'hcf_display_callback', 'post' ); } add_action( 'add_meta_boxes', 'hcf_register_meta_boxes' ); /** * Meta box display callback. * * @param WP_Post $post Current post object. */ function hcf_display_callback( $post ) { include plugin_dir_path( __FILE__ ) . './form.php'; } /** * Save meta box content. * * @param int $post_id Post ID …
I have MySQL 8.0.12, PHP v7.3.2 64Bit and Apache 2.4.38 64Bit installed. In theory I have everything that is needed to run WordPress locally. Through MySQL Workbench, I have tried the Host, Port, User and Password I have set up in wp-config.php and I am able to connect without any problems. For some reason however, when I navigate to my site's wp-admin/install.php I get the following: In my hosts file, I have dev.nativeleaf.co.uk set up to point at 127.0.0.1, along …
Is it possible with the standard build-in tools in Wordpress to get wp_query to only return the count of an query? Right now, I’ve a query which has several meta_queries but what the only thing I’m interested in is the actually count of the query. I know that I can use the found_posts property but the query itself generates a big overhead by query SELECT * and thus returns the whole object. I could just as easy query the DB …
I am developing a plugin for wordpress. I have created table in SQL for export ID. I need to call back this ID by adding 1. The code I use is as below This is how I query the ID in SQL table. global $wpdb; $last_id = $wpdb->get_var( 'SELECT id FROM ' . $wpdb->prefix . '_bek_exports' . ' ORDER BY id DESC LIMIT 1'); This is how I use it in the code below if ( $export_id == (++$last_id) ) …
Basically, I am using localhost through XAMPP, it has been 2 weeks since I started and and I had to reinstall XAMPP because I was having problems with ports. And now, I just started remaking my website again, using the port '3000' for apache and everything seemed to work fine until I can't even see the changed I have made from the wordpress dashboard or by just writing the domain name in the search bar, what is weird is that, …
How can I generate dynamic pages on a Wordpress website from information provided in a separate MySQL database? I have a database with Locations and I would like to have a page for each of these created dynamically. For example, I have a database entry for LOCATION1. If the location exists in the database, I would like a page such as www.example.com/LOCATION1/ and for the content to be dynamic, using information from the database.
I have a problem on a WP site. Website crashes because there is no more available disk space. Searching, i detect that wp_options table size is 12GB, but only have 1100 rows aprox: Any ideas? Thanks in advance [UPDATE 1] If i export wp_options table, drop and import, sizes reduces at 9,7mb: I had no opportunity to optimize the table with OPTIMIZE TABLE wp_options but I will try it if it happens again [UPDATE 2] Problem still here. I try …