MySQL swap one table for another?

Create a php script ( fpw-swap-thumbnails.php ) with the code below and put it in root of your site: <?php // load WordPress environment require( ‘wp-load.php’ ); $args = array( ‘posts_per_page’ => -1, ‘post_type’ => array( ‘post’, ‘page’ ), ‘post_status’ => ‘publish’ ); // get all published posts of type specified in $args $posts = … Read more

how to create table during plugin installation in side a class

You should run your register_activation_hook after creating object. class Notification { function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . ‘fnotice’; $charset_collate = $wpdb->get_charset_collate(); $sql = “CREATE TABLE $table_name ( id INT NOT NULL AUTO_INCREMENT, msg varchar(500) NOT NULL, time DATETIME NOT NULL, type varchar(350) NOT NULL, link varchar(350) NOT NULL, status ENUM(‘0’, … Read more

Loop posts in a table ordered by a custom field value

I found a solution which displays the posts ordered by the date value, and also removes the past ones. <div class=”container”> <div class=”row”> <table> <tr> <th>Artista</th> <th>Fecha</th> <th>Ciudad</th> <th>Información</th> </tr> <?php $today = current_time(‘Ymd’); $args = array( ‘post_type’ => ‘evento’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘-1’, ‘meta_query’ => array( array( ‘key’ => ‘fecha_del_evento’, ‘compare’ => … Read more

Include custom table in query

Working code: <?php global $wpdb; $date = date(“Y-m-d”); $querystr = ” SELECT * FROM wp_posts JOIN wp_ftcalendar_events ON wp_posts.ID = wp_ftcalendar_events.post_parent WHERE wp_posts.post_status=”publish” AND wp_posts.post_type=”post” AND wp_ftcalendar_events.start_datetime >= ‘$date’ ORDER BY wp_ftcalendar_events.start_datetime ASC “; $pageposts = $wpdb->get_results($querystr, OBJECT_K); ?> <?php if ($pageposts): ?> <?php global $post; ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); … Read more

How to use TOC with ACF?

You can use the the acf/save_post action to copy the content from your custom ‘full_text’ field over to the normal post content field, so it can automatically be accessed by toc+ and other plugins. add_action( ‘acf/save_post’, ‘wpse199256’, 20 ); function wpse199256( $post_ID ) { global $wpdb; $post = get_post( $post_ID ); $wpdb->update( $wpdb->posts, array( ‘post_content’ … Read more

Need help for creating custom table on wordpress

I guess, you can use the following function public function pre_install() { global $wpdb; require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’); $sql=” CREATE TABLE IF NOT EXISTS `”.$wpdb->prefix.”prelauncher` ( id mediumint(9) NOT NULL auto_increment, username tinytext NOT NULL, email varchar(255) NOT NULL, PRIMARY KEY (`main_id`) );”; dbDelta($sql); } and than your activation hook. register_activation_hook( __FILE__, array(‘main_class’,’pre_install’)); I dont think … Read more

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