Detect Post Type when publish_post is ran

publish_post will give you a second parameter if you ask for it. Notice the fourth parameter of the add_action call. That is your post object. function run_on_publish_wpse_100421( $postid, $post ) { if (‘news’ == $post->post_type) // your code } } add_action(‘publish_post’,’run_on_publish_wpse_100421′,1,2);

How to add a checkbox inside the “Publish post” widget?

Hook into post_submitbox_misc_actions and print the checkbox: add_action( ‘post_submitbox_misc_actions’, function() { ?> <div class=”misc-pub-section”> <label><input type=”checkbox”> click me</label> </div> <?php }); Wrap the code in a <div class=”misc-pub-section”>, otherwise the spacing looks a little bit weird. Examples: language selector, noindex checkbox, public preview checkbox.

How to make scheduled post preview visible to anyone?

Draft previews Take a quick look at this chunk of core code in query.php which [Checks] post status to determine if post should be displayed. http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php#L2658 if ( ! is_user_logged_in() ) { // User must be logged in to view unpublished posts. $this->posts = array(); } …is what makes it somewhat non-straightforward to bypass for … Read more

Publish posts only after the condition is met

Setup cron job You want to do some action (i.e. publishing a post) periodically, so first you need to schedule a cron job. Cron jobs are actions, that are fired periodically at some sort of a time interval. You can either use (non-perfect) WordPress Cron or replace it with a real cron job on your … Read more

Publish Post After Click On A Link

When the post is created and set to pending, build a unique identifier for auto-publishing, for example: $unique = md5( $post->post_content ); add_post_meta( $post->ID, ‘_auto_publish’, $unique ); Now create a link for the email: $link = get_permalink( $post->ID ); $link = add_query_arg( array( ‘autopublish’ => $unique, ‘pid’ => $post->ID ), $link ); Send this link … Read more

Prevent publish status/date saved on transition_post_status hook

I think that hook fires after the post status has been updated. Try this add_action( ‘pre_post_update’, ‘intercept_adherence_publishing’, 10, 2); function intercept_adherence_publishing ($post_ID, $data ) { if (get_post_type($post_ID) !== ‘protocol-adherence’) { return; } $post = get_post($post_ID); $adherence_status = $_POST[‘_adherence_status’]; if ( ( $data[‘post_status’] === ‘publish’ ) && ( $post->post_type == ‘protocol-adherence’ ) && ( $adherence_status !== … Read more

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