$wpdb is not initiating

You have written $wpdb incorrectly (3x) in your code example. If it is an exact copy it will never work. And you have a space in your SQL after prefix.’ which shouldn’t be there. And ‘From’ shoul dbe all caps. Try this: global $wpdb; $sql=”SELECT * FROM ” . $wpdb->prefix . ‘my_first_plugin’; $result = $wpdb->get_results($sql);

What does wp_term_taxonomy.parent reference?

WordPress doesn’t use actual FOREIGN KEY constraints in MySQL. So, technically, wp_term_taxonomy.parent is merely an integer. However, what you’ve found is correct: it refers to a term in wp_terms by its term_id. But, as you’ve also noticed, the term_id and term_taxonomy_id should always be the same. The reason they both exists is historical. Prior to … Read more

is wordpress stores Role Id in WP database?

The “ID” of the role is the array key in wp_user_roles. The value of wp_user_roles looks like this: Array ( [administrator] => Array ( [name] => Administrator [capabilities] => Array ) => Array ( [name] => Author [capabilities] => Array ) ) In that example, administrator and author are the closest thing there is to … Read more

Export SQL query based on post type

In your WordPress Dashboard, if you go to Tools > Export, you can select your custom post type and export only posts in that post type. It gives you the option between All Content, Posts, Pages, and your custom post types following those three options. As for SQL, well are you looking to export the … Read more

Convert user passwords to MD5?

It is possible to write code to grab the user’s password on login and write it out in a different format to a different location. Over time, you would thus accumulate the passwords in a different format than WordPress itself uses (it makes use of the excellent PHPass library for password storage). To do this, … Read more

Defining the same price to all WooCommerce Products

Looks like you are not familiar with WordPress Bulk Edit. Change the Screen Options to show all the products you have (if there are too many this can be slow, and is better to do it following some 100/200 product per page). Select all the products, select Edit in the Bulk Edit dropdown and Apply. … Read more

Copyright: Get first and last date of post type

There was an issue with the code originally posted by kaiser in that it queried for year, month and day distinctly resulting in values representing “the largest month for any date” or the “smallest day for any date” rather than values representing the MAX and MIN dates globally. I altered that original code to query … Read more