Articles of hooks

Can an RSS item be altered with a hook?

I would like to alter the content of each item in a site’s RSS feed with a regular expression. The rss2_item hook is close but it is run just after the item has been output, so is only really useful for adding data to a feed item, I need to alter the item with a […]

WP_query hooks before execute a search query

Anybody knows if there’s a hook before execution of a search query (not in main loop) in order to change the ‘s’ parameter to avoid WordPress’ phrase splitting? Examples are welcome… thanks P.S.: I’ve also tried in this way as follow, but the first part of sql query seems to indicate that WP have already […]

Send admin to a different login than users?

I have created a separate login page on /login/ and have wp-login.php redirecting there as well – I have also hooked into a few WP login related hooks such as wp_login_failed so that people get redirected there. However I have now decided I want admins to continue to be able to login from the standard […]

Customize title, description and focused keyword

I would like to customize focused keyword, SEO title and meta description, but I am unable to find any clue how to do it. There is official documentation but it is sooo lacking… I came up with this for changing title, but this is directly changing the title for a page, it won’t affect meta […]

pre_get_comments or the_content filter

What is the best practice to show social icons always on all the posts and pages. Already I am firing pre_get_comments in my functions.php to show a sidebar between the post content and the comments. Also I added the code after the_content() of page.php… The Question: How can I choose the propper Hook? Fire pre_get_comments […]

Passing variable in hooks and filter

I was trying to pass variables in filtes. This works perfectly for me. class my_class { function my_class() { add_filter(‘wp_list_categories’, array(&$this,’cat_count_span’)); } function cat_count_span($links) { $links = str_replace(‘</a> (‘, ‘</a> <span>’, $links); $links = str_replace(‘)’, ‘</span>’, $links); return $links; } } new my_class(); But now I want to execute the filter based on theme options […]

Plugin: Hooking up classes that have their own hooks

Was wondering if there is a “best” approach to hooking up classes that has their own hooks, still making sure that those hooks haven’t run before the class got a chance to declare it’s own said hooks. I’m getting lost in the hook hierarchy in the context of an OOP plugin, and I’d rather not […]

How to cancel an action hooked to untrash_post? or any hook

I want to do the following in a plugin: – hook to untrash_postwith a custom function – do some checking inside custom function – cancel actual post restoring (untrashing) I’ve tried with remove_action but doesn’t seem to work. Can you point me into the right direction? Code sample: add_action( ‘untrash_post’, array( __CLASS__, ‘static_untrash_handler’ ) ); […]

I need to hook and change language of facebook sdk

I need to hook into this function to change language to from en to french facebook sdk. $facebook_sdk_src = apply_filters( ‘bimber_facebook_sdk_src’, ‘//’ ); So I only need to change this url on second, and I need to add or apply some filter. So how can I change this url part //

Insert Content Before div#main from the functions.php File

I know WordPress has a filter for targeting the content in the functions.php file: add_filter( ‘the_content’) However, is there a filter to insert content BEFORE ? ‘the_content’ filter puts content AFTER div#main. I’m looking for something like: add_filter( ‘before_main’) Does a filter like that exist?