Tagged Questions
1
vote
2answers
85 views
Trouble understanding apply_filters()
In apply_filters()
apply_filters( $tag, $value, $var ... );
I'm having trouble wrapping my head around the $value and $var. I read the codex and it sounds like the $value can be modified, $var not, ...
0
votes
1answer
24 views
How can I add a filter to a particular post format?
I have several post formats and I want to use add_filter selectively, applying the filter to some of the post formats but not all. When I do this in my functions.php file it affect all the post ...
1
vote
1answer
66 views
Gravity Forms field entries into wp_query loop
I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)...
add_action("gform_after_submission_18", "set_post_content", 10, ...
0
votes
0answers
58 views
custom styling for woocommerce categories
I am using hooks and customizing the template files to use woocommerce. On my products page I want a list of categories along the top like this. I would even settle for a neat list of them where my ...
0
votes
1answer
49 views
Catch and display error on save_post action
I wrote this function that adds data to an external db every time a custom post called 'event' is created. How can I prevent the save from happening if this function returns an error? At the moment, ...
0
votes
0answers
60 views
How to add custom button to new media upload interface
I am developing a plugin and i want to add my own button to the wordpress media upload interface (WP version 3.5). Right next to the standard 'insert into page' button, i want my button to be there, ...
0
votes
1answer
26 views
Filter post before *editing*
I know there are a lot of hooks in WP for altering a posts content (and other fields) before the post is written to the DB upon saving; but what I am interested in doing is running my custom filter ...
0
votes
1answer
67 views
Does the 'nav_menu_css_class' filter accept 2 or 3 arguments?
I've been using the nav_menu_css_class filter in one of my plugins, implemented as:
add_filter( 'nav_menu_css_class', 'wbwcrf_nav_menu_css_class', 10, 3 );
function wbwcrf_nav_menu_css_class( ...
1
vote
2answers
116 views
How to modify post content before writing to database?
Hi~ I'm back again and I'm trying to add another function to the script I was working on a plugin that notify my friends of new post that mentions(@) them. Now I want to change the plain text of my ...
0
votes
2answers
64 views
How to use the 'comments_number' filter?
I'm not sure how to use this filter. Could someone show me an example? I'm trying to change ('0', '1', '%') to ('0 Comments', '1 Comment', '% Comments').
I'm using this function to get the comments ...
0
votes
2answers
59 views
Action hook to control access to certain parts of my site
I'm searching for an action hook which I can use to control access to certain parts of my Wordpress site. I want to write some custom PHP which will check certain user attributes and decide if they ...
2
votes
1answer
36 views
Hook to edit an column on comments screen?
At the moment I'm doing
add_filter("manage_edit-comments_columns", function($columns) {
unset($columns["author"]);
$columns_one = array_slice($columns,0,1);
$columns_two = ...
0
votes
1answer
177 views
Admin post list - adding an option to the date filter dropdown
I've been asked if I can add an option for "Today" and "Yesterday" to the date filter dropdown at the top of the post list in the WordPress admin view. (This is the list that shows recent ...
0
votes
3answers
64 views
Need to return shortcode text instead of the output
Is there a way I can return the shortcode text instead of the output.
My code function is hooked into 'the_content' and I know if my function contain shortcode it will automatically generate the ...
2
votes
1answer
85 views
How to remove the Theme Customization Button from the dashboard and themes options page?
In my Wordpress theme that I've currently been building I do not take advantage of the Wordpress Theme Customization API. As much as I would like too, I've invested far too much time into my own ...
-2
votes
1answer
45 views
str_replace css meta tag?
I'm trying to modify the css meta tag and make use of a CDN url - and other things.
What I have tried (as a quick test) is :
function change_stylesheet_loc($uri)
{
$uri = ...
1
vote
3answers
105 views
How can I filter blog name?
I want to filter the blog's name for Google's user agents.
I have tried the_title, the_content, comment_text, single_post_title, wp_title, category_description, bloginfo hooks, but none of them ...
1
vote
1answer
99 views
Alter image output in content
I'm trying to implement the JAIL javascript into my WordPress install. The javascript requires me to add a data-attribute and change the output html of images.
I have been looking through the codex ...
0
votes
1answer
61 views
How do I replace title with my plugin?
I am developing a plugin for WordPress 3.5. My blog's default title is "Test". Here is some code of my plugin:
add_filter('wp_title', 'my_replace_title');
function my_replace_title(){
return ...
0
votes
1answer
1k views
Woocommerce Product Category Widget - hide categories that have no products in stock
I'm using WooCommerce on my Wordpress site, and have a widget in the sidebar showing all product categories. It's setup to hide empty categories, and that works well. However, it still shows ...
1
vote
3answers
78 views
When to use actions and when to use filters
I'm trying to understand where to use filters and where to use actions.
Suppose I have a query in a plugin, which later add on modules might modify to change the results of the query, thus modifying ...
1
vote
2answers
60 views
Failed to invoke other hook from the init hook
Related to this question (Use wp init hook to call other hooks?) but not the same.
Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g.
Not Work:
...
0
votes
1answer
393 views
Filter WooCommerce Orders
I am using woocommerce for a "multi-seller" system. Meaning one site (no multi-site), but many sellers with different products.
To let each owner only manage it's own orders, it would like to filter ...
2
votes
5answers
236 views
How do I make a theme “plugin-ready”?
How do I revise a theme so that I can publish my event hooks and anyone can build a plugin to add new functionality easily to my theme?
2
votes
2answers
188 views
How To Determine If A Filter Is Called In A Sidebar/Widget Context?
So I have a plugin that appends or prepends an enhanced author biography to the content of a page/post/custom post type.
It does this by hooking to either the_content or the_excerpt and ...
1
vote
1answer
59 views
How to debug removal of rewrite rule flushing?
I use Custom Post Types. I try this:
functions.php
add_action( 'admin_init', 'flush_rewrite_rules' );
Now I’d like to remove this again. I try this:
remove_action( 'admin_init', ...
1
vote
1answer
81 views
Strange behaviour with add_{$meta_type}_metadata | add_post_metadata filter
I'm unsuccesfully trying to use the add_{$meta_type}_metadata. This filter is called inside add_metadata function (wp-includes/meta.php:31 in Wordpress 3.4.2).
In particular I wanna hook ...
0
votes
1answer
90 views
How to access variables in the function where apply_filters() is called?
I am trying to filter some data based on whether a variable from within the function that calls apply_filters() is equal to specific value. That variable is not passed to the apply_filters() ...
4
votes
2answers
90 views
Valid characters for actions, hooks and filters
I haven't ever seen a tag such as do_action('something_10'). Is it invalid if I use numbers?
If the method is valid, how can I write different numbers in the tag string conditionally? For example, is ...
0
votes
1answer
77 views
manipulate a plugins shortcode
I want to add some javascript directly below content, added by another plugin's shortcode.
We are using the NextGen Gallery plugin and there are many articles containing the [nggallery] shortcode. I ...
0
votes
1answer
76 views
Force resize for all video content
I'm looking for a way to force all video content on my site to scale to 100% width and I'm hoping to avoid using any additional javascript.
Is there a filter or function that I can use to accomplish ...
0
votes
0answers
76 views
Set-screen-option Filter Not Called [closed]
Hello, world!
I'm working on an administration panel for a theme I'm developing. The task I am working on now is adding a "Screen Options" tab for a list table. I have the page load hook in place, ...
0
votes
1answer
158 views
What filter or action hook to use in order to load some code before the template begins printing in BuddyPress?
I would like to load some code before the template begins printing in BuddyPress. What filter or action hook should I use?
I tried a number of them (such as bp_head, bp_include, bp_init), but none of ...
0
votes
1answer
91 views
Modify message displayed on post save
After a post is updated there is a message displayed, how can I change the displayed text? I would like to remove the "view post" link and change the 'Post published' text. I'd like to do this for a ...
0
votes
2answers
57 views
Which hook should be used in this case?
I'm using the enter_title_here filter to modify the 'Enter title here' text in a custom post type, question is what hook should I use to trigger this function?
I have used admin_enqueue_script as a ...
0
votes
2answers
77 views
About Hooks and Filters
Well, am having a very hard time understanding the difference between Actions and Filters. I do use actions in my code, but am a rookie and I don't know even a slightest bit of Filters.
I have been ...
1
vote
1answer
449 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
234 views
How to only hook on Single.php after content?
I am currently hooking on the_content() but that goes through the Wordpress loop too. How can I only hook on the Single.php page?
Also, is there a way to only look on the first X posts in the ...
1
vote
2answers
82 views
Too many actions/filters!
New to wordpress here. The concept of actions/filters in and of itself is not too difficult to grasp. What I am overwhelmed by is the HUGE amount of actions and filters available. When I am looking at ...
2
votes
2answers
188 views
Load different template file when condition met?
If I visit a page on my WordPress site, WP goes and determines what template file it should use based on the template hierarchy.
If I'm doing some logic checking in the hook init and say my ...
1
vote
1answer
172 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
1answer
289 views
Filter all html output
I would like to make sure no email address is published in plain. So i developed a plugin that replace all email addresses by a spambot-safe alternative.
But some users put their email address in ...
1
vote
1answer
109 views
filter the_title problem in nav
Hi I have a problem with the_title filter:
I have this code at my constructor:
add_filter( 'the_title', array($this, 'change_title') );
and this as callback (for testing purposes)
public ...
0
votes
1answer
228 views
Changing the text of Upload/Insert on Posts and Pages Screen
In wp-admin/includes/media.php I found this:
function media_buttons($editor_id = 'content') {
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
$img = '<img ...
7
votes
1answer
1k 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 ...
0
votes
1answer
777 views
NextGEN Gallery: Adding drop-down menu widget to gallery view without modifying plugin code
In NextGEN Gallery, I am able to add a dropdown menu that lets users filter a gallery to only show images that are tagged with a specific ngg_tag, simply by adding this to view/gallery.php in the ...
1
vote
3answers
1k views
How to hook wp_list_pages?
How can I hook the wp_list_pages function so that it reads a value of a custom field and displays it instead of displaying the page title?
2
votes
1answer
231 views
Change WordPress RSS link with filter?
In my theme i use add_theme_support( 'automatic-feed-links' ); to enable the rss links.
But i want to create an option to use Feedburner for the main rss feed, my problem is that i don't know how i ...
0
votes
2answers
284 views
Where exactly does the edit_{taxonomy} hook fire?
I'm at my wits end. I'm beginning a project that may involve using an action hook in WP that is not well-documented: edit_{$taxonomy}
I'm trying to determine exactly when this hook runs, so I just ...
2
votes
2answers
796 views
How can I remove css from a child theme?
I am using the theme twentyten as a parent theme for my child theme. I have other stylesheets I want to use and so I'm trying to figure out how to wp_deregister_style for the style.css sheet that is ...