Accessing data from a non-WP database/table within a page content

<?php $mydb = new wpdb(‘uid’,’passwd’,’database’,’localhost’); $mydb->show_errors(); $query = “SELECT DATE_FORMAT(col1, ‘%d-%b’) AS Pdate, DATE_FORMAT(col1, ‘%Y’) AS Pyear, col2, col3, col4, col5 AS fname FROM table ORDER BY col1 DESC LIMIT 50”; $result = $mydb->get_results($query); echo $mydb->num_rows . ‘ in table ‘; ?>

Order By table field comment_status in WordPress > 4.0

Here’s a way to add an extra Comment Status field to the posts list table: add_filter(‘manage_post_posts_columns’, function ( $columns ) { $_columns = []; foreach( (array) $columns as $key => $label ) { $_columns[$key] = $label; if( ‘title’ === $key ) $_columns[‘wpse_comment_status’] = esc_html__( ‘Comment Status’, ‘mydomain’ ); } return $_columns; } ); add_action( ‘manage_post_posts_custom_column’, … Read more

Better action hook for creating table than after_switch_theme and switch_theme action hook

Ah I found it. You can use after_setup_theme action hook. So it will be like add_action(‘after_setup_theme’, [‘\Recruitment\recruitment’, ‘create_table’]); Updated Code $theme = wp_get_theme(); if ( $theme->name == ‘My THEME NAME’ ) { global $wpdb; global $charset_collate; $sql = “CREATE TABLE IF NOT EXISTS … $charset_collate;”; require_once ABSPATH . ‘wp-admin/includes/upgrade.php’; dbDelta( $sql ); add_option( ‘ab_db_version’, self::$db_version … Read more

Change WordPress prefix for only one table?

In wp-config.php for your second site, define the following two constants: define(‘CUSTOM_USER_TABLE’, ‘yourfirstprefix_users’); define(‘CUSTOM_USERMETA_TABLE’, ‘yourfirstprefix_usermeta’); You’ll have to add some custom logic to your second site limiting logins by user role.

Get Value from Column in Plugin Table [closed]

These bigger plugins are often “too cool” to use post_meta/post_custom – thats why you were unable to retrieve the data via the normal plugin way of storing additional info. The dev documentation for ai1ec in bleak, I couldn’t find any functions to simplify the task you were after (though they do exist in the source … Read more

WordPress mysql table double prefixes

1) In order to check what kind of prefix used by current installantion you can goto wp-config.php in a root directory and find line with $table_prefix = ‘PREFIX_HERE’; variable 2) Backup the DB before making any action! 3) Additionally check if other tables with different prefixes/name_patters are not used by badly-written 3rd party plugins. They … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)