WordPress Custom Hook with Class method

You can use an anonymous function with PHP’s use statement like so: function mycars($mycarsclass){ $args = array( ‘car1’ => ‘Volvo’, ‘car2’ => ‘Toyota’ ); $mycarsclass->add_node($args); } add_action(‘mycarsaction’, function () use ($mycarsclass) { mycars($mycarsclass); }); do_action(‘mycarsaction’); or declare a separate function and pass that: function mycars($mycarsclass){ $args = array( ‘car1’ => ‘Volvo’, ‘car2’ => ‘Toyota’ ); … Read more

WP_CONTENT_DIR disables plugin directory

@tom-j-nowell Thanks for your reply… Late last, night I finally cracked the problem using this solution, which I advise everyone to add to their dev notes if you have to migrate wp sites: solution: define(‘WP_CONTENT_DIR’, ABSPATH . ‘wp-content/’ ); define( ‘WP_PLUGIN_DIR’, WP_CONTENT_DIR . ‘/plugins’ ); In my case, I migrated a multisite from a LAMP … Read more

How to change my 3000 Published post status to Draft using PHPMyAdmin

If you have access to phpMyAdmin you can run this SQL query directly: UPDATE {prefix}posts SET post_status=”draft” WHERE post_status=”publish” If you do not have any experience with SQL queries then you should use this solution. Just place this code in functions.php and refresh the WordPress once, and it will be done. function setPostsToDraft() { global … Read more