A name for an event that is executed at specific points throughout the WordPress core.

learn more… | top users | synonyms (2)

0
votes
1answer
419 views

comment_post callback function: how to run it in the background.

I'm calling a custom function when someone submits comments using the following to plug into the comment_post action: add_action('comment_post', 'MY_FUNCTION'); The problem is that my function is ...
0
votes
1answer
325 views

add action for displaying posts using a shortcode

I'm developing a simple plugin for letting a user insert a post from the frontend. I have a shortcode [add-post] which a user can put on any page, say, for eg. My Wall Page Now on My Wall Page a ...
1
vote
1answer
911 views

How to modify the action attribute of the wp-login.php?action=register form?

I'm trying to create a reference registration system in Wordpress. The idea is that the user will click a link which will contain wp-login.php?action=register&ref=12345 I'm hooking into the ...
3
votes
3answers
2k views

How to correctly get post type in a the_title filter

I want to prepend text to the post titles of a specific custom post type, but the filter below didn't work. Instead of changing only that CPT's post titles, it changed all titles on the given CPT's ...
0
votes
2answers
813 views

Editing wp-config.php

I need to add the line define('WP_POST_REVISIONS', false); to my config.php , so that post revisions are disabled. I don't have access to wp-config.php, I have permission to edit my theme and ...
6
votes
1answer
2k views

add_role() run only once?

I was surprised to discover that add_role() modifies the database and fails if the role already exists. There are two implications here, one first more serious than the other: 1) if you're in ...
0
votes
1answer
422 views

Using add_action before add_filter on a plugin?

I'm writing a plugin and having a problem. I have add_action('publish_post', 'sender'); and I want this function to run first before the add_filter function, although it won't. Is there a way to do ...
0
votes
1answer
57 views

Is there a way to figure out which action/filter invoked a function?

I'd like a lightweight way to figure out what is invoking a certain action in an effort to provide logic for certain scenarios where I can't help to avoid a function invocation (for example, a new ...
6
votes
3answers
2k views

Conditional wp_enqueue_script on a page

For efficiency we are trying to hook some JS scripts only a certain page template of a theme that is to hold a form: page-with-form.php On the theme functions.php we've defined a init_method as ...
0
votes
1answer
65 views

Actions to use when flushing cache (when posts are added / deleted / modified)

I'm looking for a list of action tags that are relevant when you: create a post, with any method, so basically using wp_insert_post modify a post, like changing status, title, content, terms, meta, ...
3
votes
3answers
5k views

add_action with a class method is causing fatal errors

I wasn't sure if this was a PHP issue (suited for StackOverflow) or a WordPress issue (suited for StackExchange), however since my issue appears to be with the add_action() function, I have placed the ...
0
votes
1answer
165 views

I cannot include a file in my plugin settings page

I'm trying to create a settings page. If I print things within index, I can see it. If I try to include it, I can't see anything, neither errors. add_options_page('My Plugin', 'My Plugin', ...
1
vote
1answer
2k views

WordPress custom form action url

Is there any way to replace standard WordPress comments form action, which usually looks like this: <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" ...
2
votes
3answers
307 views

Is it possible to remove this action? (as it's added just before it's called)

In wp-signup.php there are these lines: add_action( 'wp_head', 'wpmu_signup_stylesheet' ); get_header(); I need to remove wpmu_signup_stylesheet from the wp_head action, but I seem to be ...
3
votes
1answer
2k views

What is the very earliest action hook you can call?

After the solution to this question was to get a function to launch BEFORE the init action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load ...
9
votes
3answers
6k views

How to enqueue scripts on custom post add/edit pages?

I'm trying to enqueue a JS script only when someone is adding or editing a custom post type I created called "recipes". Currently the script works ok when I do this: if (is_admin()){ ...
0
votes
2answers
647 views

Where do I put my add_action(… and add_filter(… and do I need to remove them?

I'm working on creating a plugin out of some custom code I use a lot, in hopes that other people find it useful too. It works, so yay! but... Here's my question: I feel like I'm missing some ...
5
votes
2answers
2k views

Earliest hook to reliably get $post/$posts

What's the earliest possible action I can hook into where I'll be able to access the global $post/$posts variables on both the front and back ends? I've tried looking through the Codex reference, Adam ...
0
votes
2answers
246 views

Action for opening edit page in admin?

I have a function that kills the media buttons on certain custom post types. I want it to load whenever any post/ page edit page opens. What's the best action to hook this up to? Thanks in advance.
0
votes
1answer
513 views

create function to call category name and slug

In several theme templates I have code to retrieve the category name and slug for the present post or category page. It is outside the loop. Here is the repeated code: global $post; $categories = ...
0
votes
1answer
238 views

Post via wp-admin and via iOS app, same hooks and triggers involved?

I've got an add_action in functions.php, the action is for save_post and the function I'm running I've named set_attachment_url. I'm simply getting the first attachment on a post and setting a custom ...
6
votes
2answers
1k views

Extract image from content and set it as the featured image

The problem: I'm posting from the Wordpress iPhone app. When adding an image, the image shows up in the description itself, which I don't like. What I'm trying to do: Remove the image from the ...
2
votes
1answer
176 views

Post IDs missing on delete_postmeta action hook

I'm using metadata in pages to store variables and do server side caching for dynamic generated PayPal buttons and other variables about the pages (page specific). I'm trying to hook the page meta ...
1
vote
1answer
583 views

Add title, post content, and category like add_post_meta and update_post_meta

How can I update/add a new title, post content, and category to a post with hard PHP code similar to add_post_meta(), update_post_meta()?
2
votes
1answer
992 views

Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!

I'm trying to automatically create terms in a certain taxonomy when a certain custom post type is published. The newly created term must be the name of the post that was published. Example: I have a ...
3
votes
2answers
751 views

Correct place to register and enqueue scripts

I'm queueing several scripts in my themes Functions.php: if ( ! function_exists('b99_init_scripts') ) : function b99_init_scripts(){ if ( !is_admin()){ ...
0
votes
1answer
202 views

Which hook to use when adding ajax to viewer-facing side?

I have a shortcode that contains a form. I want to use jQuery/Ajax for POSTing. For this, I want to add javascript to the page where shortcode is added? Which hook should I use? wp_enqueue_scripts ...
14
votes
1answer
5k views

Why does save_post action fire when creating a new post?

I'm surprised by the fact that my function that I've tacked onto the save_post action fires when I click the "New Post" link in the Admin Dashboard. Note - this is before I've pressed Save or Update, ...
3
votes
4answers
2k views

Unregister post type from child theme

I'm trying to unregister a post type from a child theme but I haven't been able to do so, the code in the funcions.php file on the parent theme is something like this: add_action( 'init', ...
0
votes
1answer
246 views

I add some js files from a plugin to a specific location

How Can I add some js files from a plugin to a specific location with add_action I am Using this widget: ...
1
vote
2answers
2k 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} ...
0
votes
1answer
371 views

Fix warning: Missing argument

i want to submit a theme to the wordpress.org. when i put the define('WP_DEBUG', true); in my wp-config.php. my theme showed some errors.but i don't know how to correct theme. Q1:Warning: Missing ...
1
vote
1answer
1k views

How can I automatically set a post slug based on the post title during post publish?

When you create a post in WP, if you don't specify a title rapidly, WP generates a default slug on autosave, based on the post ID. Then, when you add the title later, unless you modify the slug by ...
2
votes
2answers
3k views

Hook/action after WP_Query gets posts to query custom tables for post-related meta

I see that there are hooks for manipulating WP_Query before it gets its posts (parse_query, pre_get_posts), but I can't seem to find any hooks for after the WP_Query object is populated. I have a ...
6
votes
3answers
5k views

How to know what functions are hooked to an action/filter?

Is there a way to know what functions are hooked to a particular hook? For example if I'd like to know what functions are hooked to the wp_head hook.
1
vote
1answer
2k views

register_taxonomy and register_post_type does not work [on hold]

I have a problem using the register_post_type and register_taxonomy on my Wordpress. I created the code on my functions.php and it does not update my panel. Why? //Categorias personalizadas ...
4
votes
2answers
2k views

Does an activated plugin automatically mean its methods are available to other WP functions?

I made a WordPress plugin like this: Class MY_CLASS { //codes } Global $myclass; $myclass = New MY_CLASS (); After installed and activated the plugin, can I use this class in other plugins without ...
3
votes
2answers
664 views

Why can't I hook into save_posts after admin_init?

I'm trying to hook into the "save_post" action from an AJAX callback in my plugin, but it doesn't seem to work. In fact, hooking into "save_posts" only seems to work from a few key action execution ...
0
votes
2answers
610 views

How to recover the post ID earlier in the WP admin hook action “firing” sequence?

I am creating a WP plugin based around Custom Post Types (CPT), where you can dynamically specify a CPT, complete with any number of associated dynamic Meta Boxes and form elements such as radio ...
0
votes
1answer
448 views

Custom post type functions.php if statement on action

I am using developing a child theme for Woothemes' Canvas. I am trying to use functions.php in the child theme to only use actions on my custom post type. This code doesn't seem to be working: ...
0
votes
1answer
103 views

How to make a function occurs for one time?

I have the following code in the functions.php file in my theme function my_func(){ echo "foo"; } add_action('admin_menu','my_func'); I assume this function "my_func" will be ...
0
votes
3answers
653 views

What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?

So the reason why I am don't want to include get_header() or get_footer() tags is because this page will be loaded as an iframe using the thickbox modal plugin and its content will be a form and I ...
3
votes
1answer
3k views

Difference between after_setup_theme and init action hooks?

What is the difference between the after_setup_theme and init action hooks? It seems they are both called right before any page in WordPress is loaded (even admin pages).
5
votes
1answer
2k views

Action hook on Edit custom post type?

Is there an explicit action hook that will fire when (or just before) the admin Edit page renders for a custom post type? Something similar to {$new_status}_{$post->post_type}? I'm trying to find the ...
2
votes
2answers
2k views

add_action('wp_ajax_[action name]', myfunction) problem

I'm having the exact same problem described in this post: add_action('wp_ajax_[action name]', myfunction) problem I set add_action('wp_ajax_my_function_call','my_ajax_function'). If I ...
2
votes
1answer
1k views

What action is called when drafts are saved?

I would like to add a metadata field to the current post based on a checkbox in a custom meta box to be able to toggle my custom plugin on a post by post basis. For this I coded the following things ...
11
votes
1answer
6k views

How to test wp_cron?

This is kind of a stupid question... I scheduled a action to run every hour: if(!wp_next_scheduled('my_hourly_events')) wp_schedule_event(time(), 'hourly', 'my_hourly_events'); ...
7
votes
2answers
2k views

Return $post_id when DOING_AUTOSAVE?

I see the following pattern over and over, on this site and on other places: add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( ...
2
votes
2answers
1k views

What action should I hook into when adding roles and capabilities?

I'm going to be using add_role() and $role->add_cap() to set up a new custom role and attach a new capability to existing roles. I'm wondering where the best place to do this is? Obviously I can do ...
2
votes
1answer
3k views

pre get posts changing the query

i need to change the posts in taxonomy.php page. I have a meta_key which i want to compare to meta value. But currently my code is not returning anything. I am sure i am missing something. Please let ...