Customizing WordPress the_title with add_filter

The issue is that you are mixing up the $title variables. $title is the parameter passed to the new_title function, but then you use it as an array: $title[‘custom_version’]. Try this: add_filter(‘the_title’, ‘new_title’, 10, 2); function new_title($title, $id) { if(‘custom_version’ == get_post_type($id)) $title=”Application has been updated to v”.$title; return $title; } I’d also highly recommend … Read more

Display WooCommerce newest product reviews on top [closed]

I couldn’t find this documented anywhere, but the solution is pretty simple. In single_product_review.php, the arguments passed to wp_list_comments are filtered: wp_list_comments( apply_filters( ‘woocommerce_product_review_list_args’, array( ‘callback’ => ‘woocommerce_comments’ ) ) ); by adding reverse_top_level to the arguments, the order is reversed. Add the following code to your theme’s functions.php: // show newest product reviews on … Read more

How to hook wp_list_pages?

A quick Google Search came up with this Source Try the following: function wp_list_pages_filter($output) { // modify $output here, it’s a string of <li>’s by the looks of source return $output; } add_filter(‘wp_list_pages’, ‘wp_list_pages_filter’);

How to disable all WordPress emails modularly and programatically?

Option 1: Remove the ‘to’ argument from wp_mail function in WordPress, it will keep your system running without sending any default WordPress emails. add_filter(‘wp_mail’,’disabling_emails’, 10,1); function disabling_emails( $args ){ unset ( $args[‘to’] ); return $args; } The wp_mail is a wrapper for the phpmailer class and it will not send any emails if there is … Read more

What params are available with the_content filter?

I don’t think there are any additional parameters passed, per se, to the_content, but global variables like $post are accessible. So something like this would work: add_filter( ‘the_content’, ‘check_for_post_parent’ ); function check_for_post_parent($content) { global $post; if ($parent_id == $post->post_parent) { //do what you want to $content here, //now that you know $parent_id //… } return … Read more

Store source permalink on XMLRPC calls

From look at source metaWeblog.newPost seems to be processed in wp_xmlrpc_server->mw_newPost() method. At the end of this method there is following hook call: do_action( ‘xmlrpc_call_success_mw_newPost’, $post_ID, $args ); which seems to be very fitting to process and save any additional information for post that have just been created by its ID provided.