Display a post’s publish date from 2112

I had the same issue as you when I was dealing with events and wanted to show future events. Here is what I coded: add_action( ‘init’, ‘change_future_posts_to_post_now’ ); function change_future_posts_to_post_now() { remove_action(“future_post”, ‘_future_post_hook’); add_action(“future_post”, ‘publish_future_posts_now’, 2, 10); } function publish_future_posts_now($depreciated, $post) { wp_publish_post($post); } add_filter(‘posts_where’, ‘show_future_posts_where’, 2, 10); function show_future_posts_where($where, $that) { global $wpdb; if(“post” … Read more

Is it possible to Schedule Attachments in WordPress?

My idea is that you can setup a post date for the attachments. This can be done using attachment_fields_to_edit to show the UI (is possible use the touch_time internal function). After that, you can filter all the attachments query to show only the attachments with a past or current date. So add_action(‘load-post.php’, ‘setup_attachment_fields’); function setup_attachment_fields() … Read more

How can I set a draft page as parent without publishing?

This works for me: add_filter(‘page_attributes_dropdown_pages_args’, ‘my_attributes_dropdown_pages_args’, 1, 1); function my_attributes_dropdown_pages_args($dropdown_args) { $dropdown_args[‘post_status’] = array(‘publish’,’draft’); return $dropdown_args; }

How can I make it so the Add New Post page has Visibility set to Private by default?

since you’re developing a plug-in, I assume you don’t want to touch any files outside of wp-content/plugins or ../themes for that matter. However, if that’s not the case, follow along: Go to wp-admin/includes/meta-boxes.php and find: $visibility = ‘public’; $visibility_trans = __(‘Public’); Now change it to the obvious: $visibility = ‘private’; $visibility_trans = __(‘Private’); Again, this … Read more

Hide permalink and preview button and link on custom post

You can accomplish the above using hooks. Use the code below in your active theme’s functions.php file to get this work delete permalink under wordpress post title add_filter( ‘get_sample_permalink_html’, ‘wpse_125800_sample_permalink’ ); function wpse_125800_sample_permalink( $return ) { $return = ”; return $return; } Customizing post link from original wordpress add_filter( ‘page_row_actions’, ‘wpse_125800_row_actions’, 10, 2 ); add_filter( … Read more

add action only on post publish – not update

Like @milo pointed out in the comment, checking if the post meta exists is the easiest way to achieve what you want – like this: add_action(‘publish_post’, ‘wpse120996_add_custom_field_automatically’); function wpse120996_add_custom_field_automatically($post_id) { global $wpdb; $votes_count = get_post_meta($post_id, ‘votes_count’, true); if( empty( $votes_count ) && ! wp_is_post_revision( $post_id ) ) { update_post_meta($post_id, ‘votes_count’, ‘0’); } } → On … Read more

How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button

You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishing actions on the post.php and post-new.php pages. It checks for a specific post type as well since all post types use these two files. function hide_publishing_actions(){ $my_post_type=”POST_TYPE”; global $post; if($post->post_type == $my_post_type){ echo ‘ <style … Read more

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