Articles of hooks

Using the 'draft_to_publish' hook (post status transition)

I am trying to use the draft_to_publish hook (http://codex.wordpress.org/Post_Status_Transitions) to run a function when a post that is a draft becomes published. This hook does not appear to be working: add_action(‘draft_to_publish’, ‘myFunction’); When I use this in my plug-in, myFunction is never fired. I have used/tested the function before. I know it is the hook, […]

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 is home.php I do this global $template; echo $template;

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?

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 id of new posts I publish. function transfer_post_id($post_ID) { global $wpdb; if (!($wpdb->get_row(“SELECT post_id FROM $my_table WHERE […]

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 = true ) ) { // …run code once update_post_meta( $post_id, ‘firstpublish’, true ); } } add_action( ‘draft_to_published’, ‘a_new_post’ ); I can’t see anything wrong with […]

Disable HTML (Text) Tab in Post Editor

I am attempting to disable the Text tab in the post editor but not having any luck. The first thing I want to do is set the Visual editor to be the default but this code does not work (it is being called from a MU plugin): apply_filters( ‘wp_default_editor’, ‘tinymce’ ); Next, I want to […]

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 they want, like a 2ndary menu/ bread crumbs etc…maybe even custom html box etc that i can do […]

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 permalink, i need some wordpress parametrs so it will be constant. Looking for this answer: global $post; get_permalink($post->ID); thx all

WordPress Hook for user register

how can I tell WordPress, that if a user registers, it shall execute my function?

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} add_action(‘new_to_publish_{post_type}, add_action(‘draft_to_publish_{post_type}, add_action(‘pending_to_publish_{post_type} … to run this script… global $user_ID; $new_post = array( ‘post_title’ => ‘My New Post’, ‘post_content’ => ‘Lorem ipsum dolor sit amet…’, ‘post_status’ => ‘publish’, ‘post_date’ […]