Looking to fill in the blanks with NULLs when there isn’t a record that is for a row that I am expecting. Consider the following wp_posts (p) ID post_title 1 Week 1 2 Week 2 3 Week 3 4 Week 4 5 Week 5 wp_users (u) ID user_email 1 email1@example.com 2 email2@example.com 3 email3@example.com 4 email4@example.com 5 email5@example.com wp_learndash_user_activity (lua)
Tag: wordpress
Wp return result from sql using AJAX
I need some help i am making a wordpress plug in. when i try to get some rows from sql thro a AJAX post i will get nothing back. Even if i try just to return a string it will stays empty. I Dont get any error . Thank you so much for helping. Script: my function: Answer You should
Simulating SELECT YEAR(post_date) SQL query using only WP Query
I’m not entirely sure this is possible but I’m completely out of ideas. The task I’m working on requires that I specifically use WP_Query due to constraints of other efficiency plugins my organization uses. Pure and simple, I need a way to simulate the following query using WP_Query: “SELECT YEAR(post_date) FROM wp_posts WHERE post_status = ‘publish’ GROUP BY YEAR(post_date) DESC”
Search a word inside post_content specifically on H1 tag [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 months ago. Improve this question As Title implies, Search the value inside the variable of $word inside the tag of column post_title content. The query should view the data of
Update table wp_postmeta column meta_value where meta_key column equals certain value
I would like to update (divide the value by 100) in table wp_postmeta column meta_value where meta_key = price_cents eg. My code: UPDATE wp_postmeta SET meta_value = meta_value / 100 WHERE meta_key = price_cents; Above SQL statemant gives me error: #1054 – Unknown column ‘price_cents’ in ‘where clause’ How to do it? Answer String literals belong in single-quotes. The string
woocommerce_tax_rates table missing from database, even though taxes are configured?
I have configured taxes in Woocommerce (with the plugin EU/UK VAT Compliance for WooCommerce). This plugin configures them inside Woocommerce, see screenshot (yes, the menu’s are in Swedish, but you get the point). So where are the taxes stored? The sql table woocommerce_tax_rates isn’t there, see screenshot. But the tax rates are clearly stored somewhere since they are visible in
Display SQL query result on front-end WordPress site
I am trying to get the total data (SUM) within a column in a Wordpress database. I am using the following SQL (and PHP) code to run the request; however, I do not know how to display the result on the front end of my site. or I have tried using print_r($avg_items_purchased); and var_dump($avg_items_purchased); but it outputs more information than
WooCommerce sql query to find products with a specific meta key and meta value
I am trying to get products with a custom field with value condition from DB. Custom field is named: “_filtered_product”. I want to get products only with value = 1 This is SQL query I have written. Answer Not sure why you want to write your own sql query for this simple task, while you could use wp_query! That being
Custom field in multiple selection
I’ve started Wordpress 1 month ago and i’ve just done my first hook into the website (just to add/remove an estimated delivery date). Once i’ve had this I was thinking that I’ve broke the website (LMAO) but it was just a postmeta problem. The postmeta value just need to be added on on every single products and be turned to
Whats the right syntax to CONCAT in wpdb?
I’m quiet new in working with wordpress database tables. So far I know because of the wpdb documentation how to update a row in a table. Now i want to achive to update the row and keep the old data in that row. I’ve read that you can use the CONCAT function to get this working but I’ve no clue