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:
- Deprecated: mysql_connect()
- dbDelta support for FOREIGN KEY
- Include WP_Query in my own PHP file?
- Include a external PHP file into a WordPress Custom Template
- is it possible to run some php code within a wordpress page?
- How to correctly submit a search form and display the result in an independent page
- How to use update and delete query in wordpress
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- How to add query vars with paginated URLs?
- Does WordPress cache get_user_meta() results?
- How to Join two tables from separate databases within WordPress
- Using Echo in ShortCode – Stuck
- MySQL query performed 4 times inside loop
- Show only one post for each author ( Page loads too slow )
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- Install will not load: PHP does not have MYSQL installed
- Modern Tribe Calendar wp-query with meta query not working at all
- WP database error for comments_popup_link()
- No wp-config.php file on local install of wordpress – site still displays
- Use ajax to update_post_meta
- integrating external php library into wordpress- the right way
- Insert all post IDs in new database table
- Is the outdated PHP mysql extension a requirement for WordPress 4.6?
- What SQL / WordPress queries would need a nonce?
- Different database query in function.php using mysqli
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- Why is variable not working on custom sql query using wpdb?
- Get WooCommerce product details and transfer them to a custom DB table
- Checking for new message using AJAX and PHP. Server overload?
- How can I export posts with featured images, without download them
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- What is a valid parent for get_terms()?
- WSoD being caused by this piece of code
- How to display data from custom table in wordpress phpmyadmin
- Calculating a large number of MYSQL queries as customshort codes, slow
- Update results, Before deleting the related category [closed]
- Sum the total amount of a specific product purchased per user and display in table
- Replacing mysql_escape_string in a custom plugin when moving to PHP7
- Weird 404 URL Problem – domain name being placed at end of urls
- wp query foreach deleting record returning only first or last item
- database sent to a JSON file
- $wpdb->insert() does not Insert record in a table
- WordPress SQL injection
- Why does abstracting html from plugin code result in loss of access to wordpress functions?
- multiple where condition in result query
- Grouping posts by a custom meta value
- Mixing variables into an array when inserting values
- wpdb prepare insert table doesn’t work
- Make a database query using WordPress
- Force Users To Relogin
- Basic wpdb update question
- A $_POST should occur when submit form but is not?
- Pull MySQL data from multiple tables and merge into 1 PHP array
- Using CFDB7 vs Custom MySQL Database [closed]
- add category to posts with tag wordpress
- Using wordpress function to retrieve data
- form $_post action value gets truncated after it passes through two forms
- Why won’t this wpdb get_results query return results?
- Adding data to custom wordpress database table
- Add row to custom database Table and delete all rows older than 1 day
- select a single val though a table in wordpress
- making php value numeric
- populate select options from extra mysql table data
- Removal of all posts content in bulk, keeping the posts itself
- How to store checkbox data for individual users?
- Please help! I have a problem with getting wordpress databas
- How to run complex query using PHP
- AWS Lightsail WordPress – connect to database on instance using mysqli
- Usermeta data unserialize, extract and display in table in WordPress
- Conditional formatting on data fetched from MYSQL
- Can I split a huge wp_postmeta table across different databases or servers?
- I can’t separate the array by commas
- WordPress mysql deos not work with php7
- How can i limit the number of posts to the most recent 6 in my query?
- Error inserting into custom table – Object of class wpdb could not be converted to string [closed]
- WP + MySql db / PHP
- The plugin generated 225 characters of unexpected output during activation
- append data to mysql table via submit button coded in php – not working
- How do I fetch a data from an external database into my wordpress homepage
- How do I fetch a data from an external database into my wordpress homepage
- WordPress select query issue
- (Who to follow) Twitter widget
- How to do a MySql query in WordPress?
- Prepared DB Query from _POST array
- Add two or multiple functions in WordPress Post or Page
- How can I display a query in a page?
- Send data from plugin to external database
- How to properly send many mysql queries via php and what happens with ajax requests after they are sent?
- How to set max users to 17.000
- Passed variable gets undefined variable error on insert on next page
- directorypress theme error mysql_error() [closed]
- How to set up an auto delete post?
- How do I / Is it possible to execute an external PHP file / function inside WordPress?
- Cannot Upload Custom Header Image into WordPress Dashboard
- MySQL update text field with ‘
- php “use” not working in template [closed]
- Predefine Magazine Style Layouts
- Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\admin\products.php on line 148 [closed]
- running an existing WordPress site from Visual Studio Code?