Using add_filter to modify a public function of a class

It means that the instance of the class is being passed to the filter callback. This might be useful if the class instance contains properties and methods that you might want to re-use in your filter. Take this example of a class: class MyClass { public function complicated_process( $value ) { // Do something complex … Read more

How can I specify the post status of an untrashed post?

I think for your purpose wp_untrash_post_status filter will be enough. Will work with single and multiple posts restore. Filters the status that a post gets assigned when it is restored from the trash (untrashed). add_filter( ‘wp_untrash_post_status’, ‘change_untrash_post_status’); function change_untrash_post_status($status){ return ‘pending’; } P.S. apply_filtershook is used to call callback functions created by us, like a … Read more

Use of comment_reply_link_args filter

You mean, something like this? add_filter( ‘comment_reply_link_args’, ‘change_author_title’, 10, 2 ); function change_author_title( $args, $comment ) { $args[‘reply_to_text’] = ‘Reply to ‘ . get_comment_author( $comment ); return $args; } Explanation: I changed the function declaration so that it accepts the second parameter ($comment) which is the comment object (a WP_Comment instance), then I simply call … Read more

Filter by category and city for doctors and hospitals in wordpress

You should register two custom post types: Doctor Hospital using function register_post_type() and then register two custom taxonomies added to both custom posts we registered above Specialty (cardiac, plastic) City using function register_taxonomy() In my opinion this is a good way to move forward

Filter content for get_the_content()

tl;dr. There’s probably a good way for you to do this in the specific case you describe, although WordPress does not allow for good, general filtering of the return value from get_the_content(). You cannot do this directly, but … There currently (as of WordPress 5.9.2, checked on 24 March 2022) isn’t a convenient, direct and … Read more