Issue with WordPress Plugin Activation Hook and Table Creation

Not sure if this helps but try doing this in the main plugin file: require plugin_dir_path(__FILE__).’inc/plugin-setting.php’; require plugin_dir_path(__FILE__).’inc/db.php’; // Register activation hook in the main plugin file register_activation_hook(__FILE__, ‘wp_comment_reactions’); Move your function wp_comment_reactions to the db.php file and call it from the main plugin file.

How to get a list of all posts and their categories?

If you want to export the data to a CSV or JSON file directly from the SQL query, you can use the MySQL INTO OUTFILE clause. SELECT wpd9_posts.post_title, GROUP_CONCAT(wpd9_terms.name) AS categories FROM wpd9_posts LEFT JOIN wpd9_term_relationships ON (wpd9_posts.ID = wpd9_term_relationships.object_id) LEFT JOIN wpd9_term_taxonomy ON (wpd9_term_relationships.term_taxonomy_id = wpd9_term_taxonomy.term_taxonomy_id) LEFT JOIN wpd9_terms ON (wpd9_term_taxonomy.term_id = wpd9_terms.term_id) WHERE … Read more

How to generate PDF dynamically based on values from the database in WordPress

Using the FPDF library (found at http://www.fpdf.org) you generate PDFs on the fly using any data from your WP site. function wpse60844_generate_pdf( $post ) { /* Define paths for where the PDF will be permanently or temporarily saved */ define( ‘FPDF_PATH’, plugin_dir_path( __DIR__ ) . ‘/fpdf/’ ); define( ‘SAVE_PATH’, plugin_dir_path( __DIR__ ) . ‘fpdf/pdfs/’ ); … Read more

$wpdb->update is not working until next page refresh. Is there one more step?

When you use $wpdb->update in WordPress, it updates the database immediately, but WordPress might still show cached data. To ensure the updated data is displayed right away, you should manually clear the post cache using clean_post_cache($pid); after the update. Here’s the adjusted code: $pid = 55276; $post = get_post($pid); echo ‘original post:<BR>’.$post->post_excerpt.'<HR>’; $newtext=”some textt2″; global … Read more

Database Errors since site updated to WordPress 6.4.3

The errors were generated because there was a plugin that forced sql modes to be used on the database that are actually “incompatible” with wordpress. The following code was sadly executed for every request… private function set_sql_mode() : void { // Make sure no sql modes can be blocked (By wordpress built-in incompatible modes) add_filter(‘incompatible_sql_modes’, … Read more