Articles of filters

Removing URL and adding container around image in the featured image metabox

I want to remove the url and add a container(div) around the image in the featured image metabox. WordPress output <p class=”hide-if-no-js”> <a title=”Set featured image” href=”URL” id=”set-post-thumbnail” class=”thickbox”>IMAGE</a> </p> at default. I want the output to be <p class=”hide-if-no-js”><div>IMAGE</div></p> Can I do this using the admin_post_thumbnail_html hook? How should I do this?

Access post ID in “content_save_pre”

First time poster, pardon my mistakes. I am trying to use the content_save_pre filter to grab a URL in the first line of a post and save it into a custom meta, and also set the post format as a link. All of that works fine, for the most part. public function save_content($content) { // […]

Add a class to post if it has been recently updated

I’m trying to add ‘updated recently’ after the post title. I’ve discovered some code which works but because of plugins and some theme coding it affects numerous instances of the_title that it shouldn’t. This issue is covered here – I’ve made some corrections / fixes but some plugins are a little beyond my capabilities. […]

How to stop the deduction in “wp_term_taxonomy” count, when the post is deleted?

In wordpress, the normal behavior is, when you delete a post, the system automatically performs a deduction of a post (-1) in wp_term_taxonomy table in count field from a taxonomy row which it belongs to. FINAL RESULT: Basically, I am looking to stop this behavior, where it could not perform the deduction when a post […]

Which Filter Do I Use To Modify The Subject Of The Retrieve Password Notification Email?

I am looking for the filter that enables me to modify the subject of the “Retrieve Password” notification Email. If you know which filter to use, please let me know.

Email Obfuscation: Is antispambot() Acceptable?

I’ve been looking into Email Obfuscation and trying to get away from obfuscation plugins when I ran across this code snippet[1]: function remove_plaintext_email($emailAddress) { $emailRegEx = ‘/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4})/i’; return preg_replace_callback($emailRegEx, “encodeEmail”, $emailAddress); } function encodeEmail($result) { return antispambot($result[1]); } add_filter( ‘the_content’, ‘remove_plaintext_email’, 20 ); add_filter( ‘widget_text’, ‘remove_plaintext_email’, 20 ); For me, this pretty much replaces any […]

Register users by e-mail

I want to use an email address instead of username to register and login my members. I’ve got the login part working using some of the code in this answer. Works fine but as expected wordpress still wants a username on the register page (custom, not the default). This line of code registers the user: […]

Add Class to a div using a filter?

is it possible to add a dynamic class to a div using a filter in the functions.php? I know it’s possible for the body-tag – also for a custom defined div with an id? if ( !is_search() ) { $customclass = ‘myclass’; }

Replace header image on all other pages but home – URL issue

I’ve got a function working to achieve what I want on my dev server, but it will not work on the live site. I have a random image implemented via shortcode and plugin, and it must appear everywhere EXCEPT the home page. This is what works on my dev server: add_filter( ‘option_woo_options’, ‘my_woo_options_filter’ ); function […]

Accepted arguments value in hook functions

Let’s say I have the following hook function: function my_function() { $post_type = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if( !isset( $_REQUEST[‘mode’] ) ) $_REQUEST[‘mode’] = ( $post_type == ‘my_post_type’ ) ? ‘excerpt’ : ‘list’; } add_action( ‘load-edit.php’, ‘my_function’, 10, 1 ); The fourth argument is (from WP Codex): (int) (optional) The number of […]