Why doesn’t global $wp_query not get hooked?

If you look at the Action Reference, you can see the order things happen. Note where init is, the query object doesn’t exist until the wp action. // … init └─ widgets_init register_sidebar wp_register_sidebar_widget wp_default_scripts wp_default_styles admin_bar_init add_admin_bar_menus wp_loaded parse_request send_headers parse_query pre_get_posts posts_selection wp // …

No result update a custom field using wp_schedule_event

It think that your problem is the you are passing the post ID as url parameter to facebook API: $url = get_the_ID(); Also, as get_posts return an array of post objects, you could use this code: $posts = get_posts(array(‘numberposts’ => -1) ); foreach($posts as $post) { $url = get_permalink( $post->ID ); $fbcount = json_decode( file_get_contents( … Read more

What hook to add at start of WordPress load

The earliest hook accessible from external code is muplugins_loaded. In order to use it, create a directory mu-plugins in your wp-content directory and put a PHP file into that directory. Sample code, will have side effects(!): add_action( ‘muplugins_loaded’, function() { print current_filter(); }); This is, of course, not “before anything else in WordPress executes”. WordPress … Read more

‘comment_post’ hook doesn’t seem to work? [closed]

Does anyone know why this ‘comment_post’ hook doesn’t seem to work!? … When a comment is posted, the function is not triggered… at all? The hook works. Try the following, it works: add_action( ‘comment_post’, ‘test_notify’ ); function test_notify($args , $args2) { echo ‘It works!’; die; } As does this: add_action( ‘comment_post’, ‘test_notify’ ); function test_notify($args … Read more

Hook for altering the content of all wp mails

Yes, there is a filter for this. The correct filter is wp_mail and is defined in /wp-includes/pluggable.php Line 135 So the code (maybe in your functions.php) should look something like this: function mail_template($args){ ob_start(); require_once (get_template_directory() . ‘/mail-templates/contacemail.php’); $args[‘message’] = ob_get_contents(); ob_end_clean(); return $args; } add_filter(‘wp_mail’, ‘mail_template’);