Method by which plugins and themes extend core WordPress functionality.

learn more… | top users | synonyms

1
vote
1answer
855 views

Add action hook conditionally - only when home.php in use

I am trying to add action hook in functions.php only if the page is home.php but the following does not work if ( is_page_template("home.php") ) { // do stuff } To make sure that file being used ...
1
vote
1answer
182 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 ...
1
vote
3answers
125 views

What are the benefit in adding hook in the init() hook?

I see a lot of plugins using this approach to add a new hook, e.g. add_action('init', function() { add_action('SOME_LATER_HOOK', xxx); add_filter('SOME_LATER_FILTER', yyy); }); Why they don't ...
1
vote
3answers
653 views

How to get url of a post from admin panel

I want to get post url from the back end edit post page, the edit post url is : www.ddd.com/wp-admin/post.php?post=1&action=edit the real post is: www.ddd.com/wp/?p=1 since the user can edit ...
1
vote
2answers
110 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: ...
1
vote
2answers
598 views

What are ideal hooks to call register_sidebars?

Where should a plugin ideally hook to call register_sidebar();? Will init do just fine? function my_plugin_register_sidebars() { $args = array( 'name' => 'foo' 'description' ...
1
vote
3answers
683 views

Is there a recover_post hook to go with trash_post hook?

I'm using the trash_post hook to set a flag in a custom table to indicate that this item is "deleted", but when the user chooses to restore that post, what hook can I use for that? I couldn't find ...
1
vote
2answers
663 views

action lifecycle

I'm looking for a documentation page where wordpress action lifecycle is explained. Does it exist? I can't understand if init is called before admin_head or viceversa (even if the name is ...
1
vote
1answer
40 views

Are posts updated or built from revisions + autosaves?

When editing a post in the admin I see records being added to the database to document my changes (here is part of the hooks I'm logging): ... http://local.dev/151-autosave-v1/ clean_post_cache ...
1
vote
2answers
521 views

Registration and Profile custom field

How to add custom field in wordpress registration form and view it in user profile in the backend? I've already google it but just find how to add it in user profile but not in registration process.
1
vote
1answer
444 views

the_posts hook, which set of posts?

I want to modify search results. Currently I hook to the_posts and check wp_query->is_search to determine if I am looking at the search results page. However, I noticed that the_posts is executed ...
1
vote
3answers
7k views

Woocommerce Product Category Widget - hide categories that have no products in stock [closed]

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
4answers
1k views

How to inject content after <body>

I would like to inject some elements directly after the <body> tag. Is that possible using only WordPress hooks?
1
vote
2answers
2k views

Hook to get image filename when it is uploaded

I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to ...
1
vote
2answers
87 views

Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || ...
1
vote
1answer
415 views

Hook up MU site creation

I want to write a plugin so I can hook up the wp_install_defaults function. I actually need to do the following: when a new site is created, I want to import a default XML file with some categories ...
1
vote
2answers
1k views

post meta data clearing on autosave

For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here: Custom field/meta populated ...
1
vote
3answers
290 views

How to find hooks as per Just-In-Time approach?

How can I follow Just-In-Time approach in hooking up my function to an action? I mean everybody just attach the functions to a very early stage like init which leaves the scope of optimisation. I saw ...
1
vote
3answers
507 views

Good tools for locating hooks in a wordpress page/admin interface/blog post?

I've recently started using the Hikari Hooks plugin for Wordpress as it seems to allow you to get a good idea of what do_actions are being called on the page, so that you can easily find out where ...
1
vote
1answer
483 views

A good way to add a different background image for each page?

I'm working an a Thematic child theme wherein I need to have a unique image decorating each of the site's main pages, from a pre-defined set of permanent images. It would also be ideal to have one of ...
1
vote
3answers
9k views

Remove title attribute from images

I'm looking for a way to remove the title attribute from images, preferably through using a hook or a filter. Most clients don't bother giving images a proper title, thus eliminating the purpose of ...
1
vote
2answers
99 views

How can i do something after head like adding a hook for after head but before post

What i mean is i am trying to add breadcrumbs to my blog and i thought of adding it before content or after title but there's an issue with that - on archive pages or category pages the breadcrumbs ...
1
vote
1answer
74 views

Question about how do wordpress filters/actions work

I have a question that I'm curious. In WordPress we can add a filter or action like this code: add_filter($filter_Name, $function_will_be_hook); add_action($action_Name, $function_will_be_hook); ...
1
vote
1answer
228 views

Change the footer text on the login page

I am customising the login page and would like to alter the footer text that takes the user back to the website. Ideally and as an example, changing it from the first image, to the second just below: ...
1
vote
4answers
1k views

Filter specific shortcode output?

Is there a hook in WordPress that I can use to filter the output of a specific shortcode? Something like this: add_filter('shortcode_output', 'my_filter_function', 2); function my_filter_function ( ...
1
vote
2answers
238 views

How to update WordPress core or themes and still have my child theme hooks work

I made a child theme based on the WordPress twentytwelve theme (i.e., the WordPress 'twentytwelve' theme is its parent). Some of the modification were done very simply by overriding style, using my ...
1
vote
2answers
28 views

Is it possible to add an action to the currently running action?

My question is very simple but I haven't found this answer yet. Here's an example: class MyClass { public function __construct(){ add_action('init', array($this, 'init')); ...
1
vote
2answers
683 views

WordPress Ajax Problems

Update I got it to fire using the following curl command: curl -H "Accept: application/json" -X POST http://localhost/wordpress/wp-admin/admin-ajax.php -d ...
1
vote
2answers
220 views

Creating a function that receives the taxonomy terms that have been changed in a custom post type

Ive been looking into actions and hooks etc... from wordpress, but cant seem to do a very simple thing. I just want to execute a function whenever a post is updated, and within the function I want the ...
1
vote
1answer
58 views

How to check if upload window came from the featured image link?

I need to verify if the media-upload screen came from a click on the "feature image link" on the admin screen. How can i do it? I've already change the way the uploader works , but I need to check ...
1
vote
2answers
1k 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
1answer
122 views

How to Remove the “Restore” Link in Quick Edit?

I want to know is there any hook to remove the Restore link in the edit page - trash page? /wp-admin/edit.php?post_status=trash I know I can hide it with a css/jquery trick, but I prefer to use a ...
1
vote
1answer
38 views

Is there any way to allow a plugin to write over a previous version?

When installing a plugin, it will not install if the directory to which it is attempting to install already exists. This means that users of our plugin must first manually deactivate and delete the ...
1
vote
2answers
2k views

Adding custom text in items titles from wp_nav_menu()

I need to add something after each title of a specific menu called by wp_nav_menu() I tried add_filter('wp_nav_title', 'testing_stuff'); with function testing_stuff() { $item->title = ...
1
vote
2answers
157 views

how to determine how many and what kind of arguments are passed to hooks

I am not able to understand a very logic behind add_action / add_filter Consider following example: function SearchFilter($query) { if ($query->is_search) { $query->set('post_type', ...
1
vote
1answer
571 views

How can I tell if I'm on a login page?

There are functions for is_home(), is_blog() is_single() etc... What's the best way to tell if I'm on a page that is requesting that I login? I guess that would just be the wp-login.php page.
1
vote
1answer
747 views

functions.php conditional tag - only show in single.php?

//Geo Map add_action( 'woo_post_inside_after', 'my_geo_mashup' ); function my_geo_mashup() { global $post; if ( in_category('listings') ) { echo GeoMashup::map(); } } Works to ...
1
vote
1answer
1k views

How to check if certain plugin exists and in expected version

I've created plugin that goes to wordpress plugin repositories. Now, I need to create another plugin (sub plugin or child plugin you may call) that require this certain plugin to be already installed ...
1
vote
1answer
32 views

Namespaced action and filter tags

I'm upgrading several of my plugins to use PHP namespaces, so that functions, classes, constants etc are all namespaced correctly. <?php namespace my\plugin; function init() { ... } // ...
1
vote
1answer
86 views

Searching hook to set cookies before <head> and avoid “headers already sent”

I have written a plugin that sets cookies, and need to avoid the "Headers already sent" PHP error by placing the code at the very top before the head section. Themes usually place wp_head just before ...
1
vote
2answers
42 views

Fatal error: Class not found in

I am working on a plugin for 'hooking' an extra payment provider into a checkout system. I have a class gtpCheckoutData in my function.php which calculates the prices. In my plugin I want to use ...
1
vote
1answer
30 views

Add parameter (time) to oembed

I need to add a time parameter to the YouTube oEmbed callback. This time parameter should be set via URL. I found various answers which describe how to hook into the oEmbed callback, but none of them ...
1
vote
2answers
47 views

apply_filters/do_action tag characters limit

Does apply_filters/do_action $tag name have a characters limit? Can be any problems if the tag name is way too long? I ask this because I know that WP transients have a limit of 45 characters. FYI, ...
1
vote
2answers
133 views

Define custom Page Template without its own .php file

Is there any way of defining a Page Template from some function/filter/hook, without having any .php file containing the comment at the top of the page to declare the Template Name? For example, ...
1
vote
1answer
85 views

How to hook in after user's registration email has been sent?

I want to redirect to a page after the user's registration email has been sent. What is the correct hook? user_register is too early, that is the user is entered into the database but the email ...
1
vote
1answer
205 views

Setcookie works on admin but not front end

I have a simple function to set a cookie to the value of whatever parameter is attached. For example, if I visit http://example.com/?devsource=http://dev.example.com/ it should set the value of the ...
1
vote
1answer
49 views

How to find a callback attached to a bbpress hook?

bbpress has a large number of callbacks attached to various hooks. I am familiar with this feature at the wordpress level but I am unable to locate where bbpress registers a large number of these ...
1
vote
2answers
67 views

How to place HTML below the title of the (custom) post overview

Edit: Yes, I know, I provided an answer to this question myself. However, I'm still interested in other solutions and/or comments on the one I found. Is this how you would do this? Are there any other ...
1
vote
1answer
142 views

Filter or action hook to insert content on admin pages before </body> tag

I am developing an administrator plugin and want to be able to write some HTML content just before the last body tag . This content will initially be hidden then displayed with javascript when a user ...
1
vote
1answer
72 views

Redirect logged in users if they are on a specific page

I'm trying to prevent a user access besides the admin to the registeration page and reset password page if they are already logged in. I have the following: function redirect_loggedin_users() { // ...