Function to execute when a post is moved to trash .

This will do the trick! add_action(‘trash_post’,’my_trash_post_function’,1,1); function my_trash_post_function($post_id){ if(!did_action(‘trash_post’)){ // do stuff } } Here we add the function, and to prevent the hook from executing more than once using did_action: http://codex.wordpress.org/Function_Reference/did_action As always, these kinds of hooks take the form {post_status}_{post_type}, so trash_post, trash_page, trash_customposttype, publish_page etc

Possible to change the URL for the regular post type without affecting the URL of other custom post types?

You could do this on custom post type registration. 1) Set your default permalink in the WordPress admin to your desired structure e.g.: /blog/%postname% 2) Add the “slug” and “with_front” parameter to the rewrite-array in the register_post_type function. “slug” must be the name of your post-type. $args = array( // … ‘rewrite’ => array( ‘slug’ … Read more

How to get post creation date?

The post_date and post_date_gmt serves as the date that the post was created. For scheduled posts this will be the date on which the post is scheduled to be published. There is no reliable native method to determine the date when a scheduled post was added. For scheduled posts, you can try the post_modified or … Read more

Get post content by ID

You can do it multiple ways. Following are best two ways. $post_id = 5// example post id $post_content = get_post($post_id); $content = $post_content->post_content; echo do_shortcode( $content );//executing shortcodes Another method $content = get_post_field(‘post_content’, $post_id); echo do_shortcode( $content );//executing shortcodes After Pieter Goosen suggestion on apply_filters. You can use apply_filters if you wanted the content to … Read more

Rewriting post slug before post save

The following is to be taken more as a proof of concept rather than a copy/paste-ready solution. That being said, this is how you’d go about it: The save_post action runs whenever a post is updated or created. You can hook a callback function to it using add_action. Hence, your case would have to look … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)