WordPress has its own connection class, which can be used trough the $wpdb object.
Is there a particular reason to use direct queries to the db, instead the wordpress functions (get_posts, get_post_meta, get_option)? Keep in mind that by doing this, you loose a lot of the wordpress tools, such as cache, filters, etc…
Related Posts:
- Transaction when using WP functions rather than vanilla SQL?
- Can i use php sql functions instead of $wpdb?
- How to validate WordPress generated password in DB using PHP?
- How to get the list of WooCommerce product image of a certain category from database?
- Custom query to get post names beginning with a digit
- How To Make Connection To WordPress Data Base In A Plugin?
- Changing user_nicename
- WordPress will not operate correctly
- tag search using WP_Query
- Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- How to track a users progress through pages by inserting data into WordPress Database?
- where to include a php file
- the_author_meta not working
- if statement on database query
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Sortable admin column for one meta key with three possible meta values
- WordPress Ajax Custom Query – High CPU LOAD
- Can I change a variable in a content part while calling it?
- AJAX in WordPress, sending coords data to MySQL and show after into map
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- the_author() not working outside the loop
- WordPress 3 – how are passwords stored and how do I compare to them?
- Styling images coming from another blog
- mysqli_real_connect() – authentication method unknown to the client Warnings
- Do I need to prepare query before get_results(), get_row() and get_var()?
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How to convert objects into arrays
- Ajax $wpdb not returning table data
- Is there a way to get 3+ dimensional array from a single MySql command
- Can’t get wp_insert_post to work
- I want to select the from values from database in WordPress? [closed]
- mysql query from wordpress page using custom table
- User management system similar to wordpress one?
- Importing Geo data into wordpress database
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- SQL Injection blocked by firewall
- How to check if a meta value has already been assigned to any user?
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- code is skipping a div
- How can I save unique user data on my site? [closed]
- Long running queries
- Not connecting to database in file with multiple MySQL connections
- Way to bulk make all my tags lowercase?
- $Wpdb post meta query is not working with mutliple meta keys and values? [closed]
- Correct and safe way to include php content in my page
- How do I display offsite database info on my wordpress site?
- Post’s ID pattern?
- Using WP functions such as the_title() in an included php file
- WordPress and MySQL: trying to print data using PHP from user_meta custom field data
- Use $wpdb or other PHP script method to find/replace in WP database
- email alert for product availability
- Issue with fetching mysql data and displaying results via shortcode in webpage
- How to include custom PHP file both in header and footer files
- Custom route and query
- How do I prepare strings for insertions as values into a MySQL table?
- add category to posts with tag wordpress
- How can I Use 2 databases with one WordPress install
- Edit Account – read and write to MySQL
- Why won’t this wpdb get_results query return results?
- Why when I create a new post I found 2 record related to this post into the posts database table?
- mySQL queries are executed twice on wordpress website
- Most viewed posts in WordPress
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- What’s wrong in my PHP code? I’m using WordPress Astra Theme and I can’t insert data into my SQL
- WordPress low speed after migrating to new host
- Get mysql data for Quick Edit panel
- AWS Lightsail WordPress – connect to database on instance using mysqli
- call to undefined function mysql_connect
- I am facing this error Your PHP installation appears to be missing the MySQL extension which is required by WordPress
- Using wpdb to connect to a different database is not working
- How to edit content in WordPress and the Polylang – plugin? – with demosite
- Change upload URL by mime type
- Unexpected behavior when trying to manually install WordPress on macOS Sierra
- WordPress post insertion from PHP file
- Insert data from form to database
- Query doesn’t display text data with apostrophes
- Rewrite SQL query as a prepared statement and use in foreach loop
- Prepared DB Query from _POST array
- Include a custom field in mysql query
- Conditional statement within WP SQL query
- WordPress upload images not displaying
- two wordpress sites, two themes, one database, same content
- how to check for wordpress Query errors
- Insert double entry in DB
- Splitting One Big WordPress Site into Multiple Small Sites
- MySQL database migration to WordPress
- Custom query_posts() parameter
- Shortcode not passing variable to included file
- How to edit the default database of WordPress [closed]
- Query Concatenation
- How to include a php file in every post and page [duplicate]
- wordpress.org disallowing my plugin becuase of loading core files in cron cpanel file
- Display total count of products in orders of a specific order status
- How to set variable to specific field when querying
- Getting invalid user ID error when creating a new user with wp_insert_user
- Custom form that stores data in mysql database
- Putting form result in my database
- How can I update a value of a field depending on outside source?
- How to return count number from a wordpress database
- Trying to GET data with ajax from database and show in fullcalendar