Method by which plugins and themes extend core WordPress functionality.

learn more… | top users | synonyms

2
votes
2answers
455 views

Run javascript code after wp_login hook?

After using the wp_login hook, is it possible to add a snippet of javascript code to the page seen immediately after the login in wordpress? I want to use this top implement a notification system ...
2
votes
1answer
2k views

Overriding The Loop with filter or hook

I'm trying to replace the $wp_query object for a specific category, without having to deal with creating a new template and creating a new WP_Query object there. My aim is to change the data ...
2
votes
2answers
673 views

Display info from custom fields in all images' HTML

Okay, I've been working on this all day and can't find the solution anywhere. I've created a custom field within the image upload screen (info first found here). The field stores the name of a ...
2
votes
1answer
371 views

When to call `add_rewrite_rule` for safety

I am starting to run into situations on projects where I am combining multiple plugins which all use add_rewrite_rule and flush_rewrite_rules at different points. As we all know, calling ...
2
votes
2answers
581 views

specify meta_key / meta_value condition for prev_post_link and next_post_link

I've got a custom post type (CPT) called event. Every event has got an associated meta_key called event_date. I want to make sure that events with empty event_date won't appear in my list of all ...
2
votes
1answer
2k views

Best Practices for Creating and Handling Forms with Plugins?

I'm writing a plugin that creates and handles a simple form. This has been my approach sofar, but it's turned out to have some major flaws: 1) On plugin activation, create a blank page for the form ...
2
votes
1answer
673 views

Which hooks is this? add_action('wp',

I have seen it here: wp_schedule_event Code snippet: add_action( 'wp', 'prefix_setup_schedule' ); I couldn't find this hook anywhere in documentation, how does it work?
2
votes
1answer
2k views

Custom Blog Post Listing in Genesis Sample Child Theme

I want to add several images and divs and also customize the look of my Blog post listing... But i can't find the way to do it. Here's the Blog Template code <?php /* WARNING: This file is ...
2
votes
1answer
448 views

Gravity Forms field entries into wp_query loop [closed]

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, ...
2
votes
0answers
159 views

How to add custom button to new media upload interface [duplicate]

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, ...
2
votes
1answer
118 views

How to save the values of checkbox to the register setting?

<?php function default_menu() { <form action="options.php" method="post"> <?php settings_fields( 'sample_check' );?> <input type="checkbox" name="sample" value="nofollow"/> ...
2
votes
2answers
144 views

Placement of Code in Plugin for hooking `save_post`

I ran into a strange Problem today developing a new Plugin. I set it up as usual, creating the f711-roomprice folder in the Plugindirectory, and creating the f711-roomprice.php as well as an inc ...
2
votes
2answers
160 views

add_action on inherit post status

I'm trying to use the add_action() hook to run a custom function, but am struggling with the post status. I originally tried using: add_action('pending_to_publish_portfolio', 'my_function'); ...
2
votes
1answer
105 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 = ...
2
votes
1answer
223 views

publish_post plugin hook doesn't always pass $post->post_content

I've written a simple plugin that grabs the contents of a post, as the post is published, and sends them to an external site for archiving. This generally works but when dealing with posts that ...
2
votes
1answer
419 views

Post thumbnail relative link and HTML modify

I want to remove the website url from all the_post_thumbnail() so they become relative and remove/add attributes from the output. So far I got the following code added to functions.php of the theme, ...
2
votes
1answer
183 views

Problem using role_has_cap hook

I'm trying to filter a capability check in order to work around the lack of filters to customize the user edit page in the admin area. But I can't seem to add filters to a hook, and I'm sure I'm ...
2
votes
1answer
199 views

How can I customize the upload error message in Wordpress?

After following the guide for How can I prevent uploading bmp image? to remove bmp (and in my case tiff images) from being uploaded, I tested and it is working, but noticed users are now getting the ...
2
votes
1answer
63 views

Hooks for Links Box [duplicate]

Possible Duplicate: Getting archive pages in WP's AJAX internal link finder? Are there any hooks for the new internal links box that was created in WP 3.1? I'm trying to modify it in my ...
2
votes
3answers
916 views

Is there a hook for user activation (after they click the email confirm)?

Is there a hook for user activation (after they click the email confirm)? I am creating a plugin to automatically add them to my email software, but I want them to have to confirm their email first.
1
vote
3answers
753 views

How many times can I hook into the same action?

I have a theme which includes some setup, using after_setup_theme but I'd like to write my own functions which also need to run after_setup_theme. I'd prefer to keep my stuff in a separate file. Can I ...
1
vote
3answers
438 views

Insert all post IDs in new database table

I have a plugin which creates a new database table. Upon activating the plugin is there a way to insert all my posts ids into that table? Right now I'm using an action hook to immediately insert the ...
1
vote
2answers
2k 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, ...
1
vote
3answers
98 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
4k views

How can I edit post data before it is saved?

I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the plugin api, I see that two hooks that look like they ...
1
vote
1answer
2k views

WordPress Hook for user register

how can I tell WordPress, that if a user registers, it shall execute my function?
1
vote
3answers
515 views

Why doesn't wp_enqueue_script() work when including a JavaScript file with TEMPLATEPATH?

I am trying to use tips from here to add my JS file. I put the following in the functions.php of atahualpa theme I've got installed function lektor_init() { if (true) { ...
1
vote
3answers
161 views

How and where can we request new WordPress hooks to be added?

I use the great Changelogger plugin, which adds plugin version history to the plugins page when there is an update. Although I would like it to, it doesn't work from the updates page where you can ...
1
vote
2answers
100 views

Check if do_action('custom_action') is hooked into?

Is there a way to check if a custom hook gets called upon? I would like to display a placeholder if no output will be passed to it.
1
vote
3answers
1k views

Hook on trash post

I want to perform an action when I delete one of my custom post types, which hook should I use: wp_trash_mycpt or trash_mycpt My action should run solely when mycpt is in the 'publish', 'draft' ...
1
vote
2answers
95 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 ...
1
vote
3answers
421 views

wordpress custom modules/widget areas on the page? can i make my own?

im kind of a wordpress noob so please excuse my inexperience. so long story short, ive been tasked with creating a WP theme (kinda simple) but, one of the areas, around footer area, has a few things ...
1
vote
2answers
1k views

What hook should be used to programmatically create a post only when master post is updated?

Pippin and Jean-Baptiste Jung have very good tutorials on how to programmatically create content when a new post is published using these four actions hooks... publish{post_type} ...
1
vote
1answer
1k views

Execute function when post is published

I try to use this function i have created when a post is published for the first time. function a_new_post($post){ $post_id = $post->ID; if ( !get_post_meta( $post_id, 'firstpublish', $single ...
1
vote
1answer
712 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
173 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
1answer
1k views

Why is save_post hook not running?

I am trying to save my meta box, I have something like function xxx_meta_box_callback() { add_meta_box('xxx-meta', 'xxx Details', 'xxx_meta_box', 'xxx-post-type', 'side', 'default'); ...
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
2answers
103 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
537 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
610 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
556 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
2answers
299 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
374 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
6k 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
3answers
982 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
86 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
408 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 ...