Articles of filters

How to influence the information displayed on widget inside wp-admin

First, I want to clarify – this is not a CSS question. I want to change the data that is showing of the widget, when its in closed / open mode inside the wp-admin, in a sidebar or a page builder. Here is an image to better explain. I want to be able to add […]

How to bulk delete all users with no posts?

I have 10 thousand of users about 98% of these users never published a post (i mean post not comments). I need a way to mass delete users with 0 posts. The method must count all posts included custom post types and has to use proper WordPress function to delete a user as if they […]

No filter of code on switch from html to visual editor, how?

Yes, i have found other questions to this topic, but no have the same topic exactly and no solution for my problem. If you include code inside the html-tab and you switch to the visual mode, then format WP the code to a block, remove all breaks and leave lines, see the screenshots. I think […]

wp_headers vs send_headers. When to use each?

I’ve seen wp_headers and send_headers both used before for the same thing and I’m wondering how you’re suppose to know which one to use and when… On the send_headers codex page there’s an example of adding the X-UA-Compatible: IE=edge,chrome=1 for Internet Explorer backward compatibility since the meta tag often fails on intranet sites if loaded […]

Changing JPEG compression depending on image size

Short. I want ”large’ images compressed by 90%, and ‘medium’ to be by 60%. Has many af you know, sometimes larger images suffer from high compression, but other small images don’t. This function allows to resample all the jpg images function custom_jpg_compression($args) { return 90; } add_filter(‘jpeg_quality’, ‘custom_jpg_compression’); How to filter by image size?

Removing Image and Caption Dimension Attributes

This question is an offshoot from the this discussion on removing dimension attributes from images. The solution code provided on that thread works very well except that it has the unfortunate side effect that any shortcodes are striped from the image. After several hours of digging through the core code, I found the cause of […]

add_action(), add_filter() before or after function

When looking through WordPress snippets/tutorials/plugins I often see add_action() and add_filter() being placed before the function is declared: add_action( ‘publish_post’, ’email_friends’ ); function email_friends( $post_ID ) { $friends = ‘,’; mail( $friends, “sally’s blog updated” , ‘I just put something on my blog:’ ); return $post_ID; } From a logic standpoint this just […]

How to Pass External Variables to Filters/Actions

I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I’ve seen to do this are really complicated and hard to wrap my head around. Take this example: $score = 42; //Some crazy calculation I don’t want to repeat. function add_score_to_title($title) { return ‘Quiz […]

How can I modify the WordPress default widget output?

I don’t want to style the default widget with only CSS. I want to display the default ‘Categories’ widget content with my own HTML structure. Is there available any filter or hook to do that?

How to get shortcode's input values inside a filter?

I’m trying to get the input value of a shortcode inside a function that is used by a filter, but there seems to be no success. Here is what i did: function my_shortcode_function($atts){ $value = $atts[‘id’]; function filter_value(){ echo $value; } add_filter(‘posts_where’,’filter_value’); } add_shortcode(‘my-shortcode’,’my_shortcode_function’); Now i know using $value inside filter_value() won’t work because of […]