wp_insert_post: array only. wp_update_post: array|object (?)

Array’s are technically preferred for both, but it actually doesn’t matter that much. PHP is not casting the object to an array, worpress is. wp_insert_post(), like a lot of wordpress functions, runs it’s “array” parameter through wp_parse_args() which will cast an object passed to it to an array and will always returns an array. You … Read more

wp-options keep crashing please help

It sounds like you may be running a plugin that stores too many transient options. If you can’t currently access wp-admin, try FTP’ing in and renaming your /plugins folder to disable all plugins. Then you should be able to log in to wp-admin. Next, back in FTP rename your /plugins folder back to the normal … Read more

How to call multiple functions from multiple files into a WordPress page template [closed]

Just add your functions to your theme’s functions.php file. They will be available to all of the templates within the theme. functions.php: function add_cars_specifications() { if ( in_category( ‘cars’ ) ) { echo types_render_field( ‘cars-specs’, array() ); } } In your page template file and other templates in the theme, add_cars_specifications() will be in scope, … Read more

plugin add action hook is not working :

Nothing is wrong with your code. Just change the $Wp_Admin_Bar to all lowercase function wp_add_google_link(){ global $wp_admin_bar; var_dump($wp_admin_bar); $wp_admin_bar->add_menu(array( ‘id’=>’google_analytics’, ‘title’=>’GoogleAnalytics’, ‘href’=>’https://google.com/analytics’ )); } add_action(‘admin_bar_menu’,’wp_add_google_link’);

Is a series of update_option calls safe, performance wise?

Using separate option names for a bunch of related options is not ideal. Instead, store options in a single key as a serialized array unless there is a specific reason not too. This way, you’ll only need the one call to add_option(), update_option(), and get_option() which will mean fewer queries being generated overall, particularly (as … Read more

Delete taxonomy and delete all post related it

First of all we need to find the posts related to our taxonomy term. Then we will delete them one by one by running a foreach loop. Try below code. I hope that will work for you- add_action(‘pre_delete_term’, ‘the_dramatist_delete_posts_on_taxonomy_delete’, 1, 1 ); function the_dramatist_delete_posts_on_taxonomy_delete( $term ) { $args = array( ‘post_type’ => ‘post’, // post_type … Read more