A type of hook that provides a way for content to be overridden programatically

learn more… | top users | synonyms (5)

1
vote
2answers
217 views

Clarification on filters and hooks

I am about to start my first WordPress project and I have the task of moving customized core code that override the core into separate functions/files (this way it'll be easier to maintain when we ...
21
votes
3answers
1k views

How to remove a filter that is an anonymous object?

In my functions.php file I would like to remove the below filter, but I'm not sure how to do it since it's in a class. What should remove_filter() look like? add_filter('comments_array',array( ...
14
votes
1answer
3k views

Passing a parameter to filter and action functions

Is a way to pass my own parameters to the function in add_filter or add_action. For example take a look in the following code: function my_content($content, $my_param) { do something... using ...
7
votes
1answer
4k views

How to add defer=“defer” tag in plugin javascripts?

I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in contact form 7 javascripts. This is how contact form 7 includes javascript in header. ...
11
votes
2answers
4k views

Difference Between Filter and Action Hooks?

I have been looking at the plugin API a bit more in depth recently and I was wondering what real differences there were between action and filter hooks. They both are events that receive data as a ...
11
votes
1answer
5k views

Saving Taxonomy Terms

I have an interesting problem which I hope someone can quickly answer. I have created my own metabox which, based on "MY METABOX CODE" (list below) is correctly displaying a dropdown list of all my ...
5
votes
3answers
939 views

Filter any HTTP request URI?

I want to filter any HTTP request URI done through the HTTP API. Use cases: The WordPress update check goes to http://api.wordpress.org/core/version-check/1.6/, but ...
23
votes
4answers
13k views

Filter to remove image dimension attributes?

I'm working on a site based on a fluid width css template which sets a max-width on images to the width of the column containing them, and I need to remove the inline width and height dimension ...
11
votes
4answers
4k views

single-{$post_type}-{slug}.php for custom post types

My favorite part of the Wordpress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template. We can ...
5
votes
1answer
6k views

Add filter menu to admin list of posts (of custom type) to filter posts by custom field values

This answer is very close to what I am looking to do, but instead I would like to specify a specific custom field and display a select menu of its available values. Thanks!
2
votes
1answer
791 views

How can I display parent and child taxonomies in separate drop downs?

The requirement is where i have a taxonomy State which is the parent and it has a child sub-taxonomies they are the Cities, Need to display the state as a drop down, when i select the particular state ...
0
votes
1answer
179 views

Exclude custom function content from certain pages

I have added a small custom function to display a little author bio blurb at the bottom of each blog entry in my functions.php file inside the current theme that I am using. So far so good, it is ...
12
votes
2answers
6k views

Explanation for apply_filters function and its variables

I'm learning how to build html forms using PHP by taking an example from "simplr form registration" plugin. I'm looking at this code: $form .= apply_filters('simplr-reg-instructions', __('Please ...
10
votes
1answer
449 views

How to create an API for my plugin?

I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins ...
0
votes
2answers
889 views

Make parent categories not selectable

I'd like that my categories having child-categories don't be selectable on the post article page. What I want to do is to remove the checkbox before their label. I've looked the filter documentation ...
5
votes
5answers
4k views

Remove classes from body_class

I don't need this whole mess of classes like this... <body class="page page-id-829 page-template page-template-page-template-portfolio-php portfolio"> I'd like something like this... <body ...
6
votes
2answers
262 views

current_shortcode() - detect currently used shortcode

In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended. See the plugin Public Contact Data on GitHub for details. To keep the ...
3
votes
1answer
737 views

How to add filter in “Comments” at the admin panel?

I found so many information and most of the tutorials only talk about adding filter in post/custom post only. I want to do something similar to this tutorial in 'Comments' area in admin panel. Add ...
3
votes
1answer
843 views

Update post counts (published, draft, unattached) in admin interface

I am working on a multi-user WordPress setup and have made it so a particular type of user can only see and interact with posts, images, pages etc that they have authored. The code to make this happen ...
2
votes
2answers
590 views

How to order posts of a custom post type by date DESC in dashboard Admin?

I created a new post type named "Video". When I create post for the post type, posts is ordered by title ASC. Is it possible to order posts by date DESC please ? register_post_type('Videos', ...
2
votes
1answer
385 views

What hooks/filters are there to alter selected terms on post save?

Very simple, where would I hook/filter to alter the users selection of terms when they save a post (Update or Add)? I need to hook in all instances; such as when saving a post via AJAX, saving when ...
1
vote
2answers
178 views

How can I find out what an `apply_filter` call is actually doing?

As an example, I'm looking at class-wp-xmlrpc-server.php and there's a line (~115) that says: $this->methods = apply_filters('xmlrpc_methods', $this->methods); How can I actually find out ...
4
votes
2answers
2k views

add_filter and changing output captions of image gallery

I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine (link) author advises to change whole gallery_shortcode function. But I wondered if is possible to change ...
0
votes
2answers
174 views

Override parent theme function that is not hooked or in the functions.php file

I need to remove a function from the parent theme and replace it within the child theme. The function is called print_meta($meta_box). The function is not pluggable and it located in a random file, ...
0
votes
1answer
687 views

Where is the best place to use add_filter

Should I use the function add_filter In my plugin's init action hook or just the in the main plugin script? Since sometimes I found people is using filter all over the place and if I put in the init ...
8
votes
3answers
3k views

remove_action or remove_filter with external classes?

In a situation where a plugin has encapsulated its methods within a class and then registered a filter or action against one of those methods, how do you remove the action or the filter if you no ...
5
votes
1answer
2k views

Changing WooCommerce Display Price Based on User Role & Category

I'm looking to display a different price based on a user role (wholesaler, dealer, etc) AND based on the category. There's a dynamic pricing plugin that displays these discounts once an item is added ...
4
votes
2answers
816 views

Set JPEG compression for specific custom image sizes

I use various custom image sizes (by add_image_size) and I have set my JPEG compression to 30% with this filter: function jpeg_quality_callback($arg) { return (int)30; } add_filter('jpeg_quality', ...
4
votes
5answers
583 views

Implementing advanced add_* function wrappers

add_action() and add_filter() are major functions. However in some scenarios add one more function and hook it somewhere approach gets bulky and inconvenient. I had determined for myself several use ...
6
votes
1answer
595 views

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 ...
2
votes
2answers
4k views

Add_Filter example for wp_get_attachment_link

Let me preface by saying I don't really understand Add_Filter, but I think that I want to be using it here. If not please let me know. I want to modify wp_get_attachment_link so that the link url ...
2
votes
3answers
4k views

Moving sharedaddy buttons (in Jetpack) to the top of a post?

How would one move the sharedaddy buttons included in Jetpack to be placed before a post's or page's content, rather than after it? I see that in sharing-service.php the function that prints the ...
3
votes
1answer
1k views

Is it possible to use a forgot password url filter?

i recently found that a login url filter is available but i can't find a solution for the forgot password as well, for the login url i use this: function custom_login_url($login_url) { return ...
2
votes
1answer
1k views

Rename image uploads with width in filename

I am attempting to change the name format that Wordpress uses to rename uploaded files. For example, when I upload an image with filename "cat-picture.jpg" Wordpress will create scaled versions and ...
1
vote
1answer
800 views

How to use filter hook 'post_updated_messages' in coherence with action hook 'save_post'

I am trying to send out e-mail, SMS and IM notifications to group members of this WordPress website, whenever a WordPress page in their user group has been published/updated. I figured using the ...
0
votes
1answer
759 views

How to display a shortcode caption somewhere other than the_content

I want to disable shortcode captions for posts in one of my themes, and display the content elsewhere, such as in a sidebar. The images aren't uploaded to wordpress, but they're linked-to using the ...
3
votes
1answer
184 views

WordPress 3.9 - Trouble Editing new TinyMCE

With WordPress 3.9 coming soon it's bringing along TinyMCE 4.0. I'm running my plugins and functions through some testing and found that one of my functions seems broken / not working with the new ...
3
votes
3answers
2k views

Loading template files from a subfolder in my theme?

I am working on a site that will have up to 30 templates in it. I don't want to have all those templates at the root of my theme folder cluttering up everything. I know how I can modify the ...
2
votes
8answers
9k views

Filter get_categories() for taxonomy term in WordPress

I want to show a category only if a (custom) post is in that category AND region = $name for that post. So, e.g. I have a custom post (type "business") named "Mamma Mia" in child-category: ...
1
vote
2answers
1k views

Conditional add_filter?

I need to apply an add_filter from my functions.php but only if the user has opened media-upload.php from my custom function. Is it possible to send a variable when opening media-upload.php that I ...
0
votes
2answers
372 views

Wordpress 3.5+ upload tool filter

i would like to use the brand new wp's upload tool in a personnal theme options page. I found a lot of tutorials like : wp media uploader in plugins ...and it works very fine. But i'd like to filter ...
0
votes
1answer
132 views

How-to inspect filter-able $vars?

Note: This is more of a tutorial/wiki than a real question and should be a reference for later Questions. If you got something to add, please feel free to add an answer. Working answers get upvoted. ...
3
votes
1answer
396 views

How to apply a class to the second word in menu list item?

I want to apply a class to a word in my menu. For example, say I have a list item in my menu called "My Item". I would like to apply a class to the word "Item" so that I can style it anyway I want. ...
2
votes
1answer
470 views

How to remove or replace the log-in link for comment replies?

I need to edit the function get_comment_reply_link() in wp-includes/comments-template.php. All I really wanna do is take out the "log in to reply" text is puts in every comment for logged out users ...
2
votes
2answers
1k views

Get password when user registers and save it sha1 into database

im working on a website where the users can connect with iphone to some functions of it by using a sha1 encrypted password. In other words the plain password of wordpress encrypted in sha1. In the ...
2
votes
3answers
1k views

How do I filter the excerpt metabox description in admin?

I want to change the default "Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts." help text below the Excerpt input area to ...
1
vote
2answers
2k views

What is the filter hook for custom fields content?

The following code hides "the_content" output add_filter( "the_content", "cp_module_pcontent_post_content" ); function cp_module_pcontent_post_content($content){ global $post; ...
1
vote
1answer
183 views

Change comments form title on a page by page basis

I'm looking to change the comments form title (my theme defaults this to "Leave a Comment" or "Leave a reply to"). I thought perhaps I could add a hook to comment_form_defaults but my snippet below ...
1
vote
2answers
3k views

How do I filter title and alt attributes in the gallery shortcode?

I am displaying a post gallery inside a custom post type, using the following in my single-custom.php template: <?php echo do_shortcode('[gallery id="'.$post->ID.'" link="file" columns="5" ...
1
vote
1answer
1k views

Title_save_pre - Simple problem that u know for sure

I have two custom post type. Then I need to use title_save_pre to post title prior to saving it in the database. I need to use this filter just for one custom post type. This is my function: ...