How to replace native comment_count with Comments Evolved aggregate count

Few issues here. use add_filter() instead of apply_filters(), to register your custom callback. return the value within your filter’s callback. use the get_comments_number filter instead of the comments_number filter, since you only want to change the number and not the whole output of the comments_number() function. prefix the name of your custom callbacks, to avoid … Read more

Clone a Post Tite and Custom Field into Custom Post type

Something like this should work- if( get_post_meta( $post_id, ‘_surl_post_id’, true ) ) { // we have an old post created here update_post_meta( get_post_meta( $post_id, ‘_surl_post_id’, true ), ‘_surl_redirect’, get_post_meta( $post_id, ‘url’, true ) ); return; } // Prepare contents $add_cpt_clone = array( ‘post_title’ => $post_object->post_title, ‘post_status’ => ‘publish’, ‘post_type’ => ‘surl’ ); // Insert the … Read more

How to move WordPress gallery image out of the link?

You can use the post_gallery filter for the job and replace wp_get_attachment_link() with wp_get_attachment_image(). Something like: add_filter( ‘post_gallery’, ‘post_gallery_wpse219434’, 10, 2 ); function post_gallery_wpse219434( $output, $attr) { global $post, $wp_locale; static $instance = 0; $instance++; // We’re trusting author input, so let’s at least make sure it looks like a valid orderby statement if ( … Read more

Communicating to plugins from webserver

The php code at apache, and therefor wordpress, is executed only as a response to an http request, therefor you can not “wait for event” the way you try to do. You will either have to trigger the required action via http, a specifically crafted URL for example, or load wordpress from the CLI, and … Read more