Hot answers tagged

3

WP-CONFIG file should be like below- // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ ...


1

I've checked and WordPress does, by default, retrieve & cache all post meta along with the main query's posts, so you're perfectly fine storing a product's additional fields as standard post meta. You might want to store Brands (merchants? manufacturers?) as a custom taxonomy so that you can take advantage of built-in templates and queries to show all ...


1

This is untested, but give it a go. First get a list of the term names in the taxonomy. Then filter the returned array of names against your regex. Then use that filtered array of names for your WP query. // assumes these assignments: // // $taxonomy - the taxonomy name you are querying against // $regex - the regex to match the term names against // ...


1

That's not a good practice trying to connect the DB by your own methods while WP does it for you initially. The problem with this is that I have to declare these variables ($db_host, $db_user, $db_pass, $db_name) inside the plugin source code. All these properties are defined in wp-config.php file, located in the root area. If you were to get ...


1

Why not study about how $wpdb works. Visit https://codex.wordpress.org/Class_Reference/wpdb Here is a example of how to insert data to database using $wpdb <?php global $wpdb; $wpdb->insert( 'table_name_here', array( 'column1' => 'value1', 'column2' => 123 ), array( '%s', '%d' ) ...



Only top voted, non community-wiki answers of a minimum length are eligible