Disable Attachment Pages Completely

You can filter default rewrite rules and remove those for attachments: function cleanup_default_rewrite_rules( $rules ) { foreach ( $rules as $regex => $query ) { if ( strpos( $regex, ‘attachment’ ) || strpos( $query, ‘attachment’ ) ) { unset( $rules[ $regex ] ); } } return $rules; } add_filter( ‘rewrite_rules_array’, ‘cleanup_default_rewrite_rules’ ); Don’t forget to … Read more

Post featured image column on admin post list page

This is what I’m using, cobbled together from snippets found online… It’s uses a filter on manage_posts_colummns to re-jig the headers and an action on manage_posts_custom_column to add the row level data. function custom_columns( $columns ) { $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘featured_image’ => ‘Image’, ‘title’ => ‘Title’, ‘comments’ => ‘<span class=”vers”><div … Read more

Passing current cookies in wp_remote_get to get Draft Post Preview

I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source: $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( ‘preview_post_link’, add_query_arg( ‘preview’, ‘true’, $preview_link ) ) ); $cookies = array(); foreach ( $_COOKIE as $name … Read more

Post preview mechanism architecture

Even if you hit just one button for “Preview” it may ends in 2 different “routes”. The one is something like http://example.com/postname/?preview=true The second is something like: http://example.com/postname/?preview_id=152&preview_nonce=xxx&preview=true so the first contains preview query argument, the second contains preview_id preview_nonce preview query arguments. preview query argument tells WordPress to allow visualization of non-published posts to … Read more

Set Default Listing “View” in Admin

Although having the feature of persistent settings in core is nice, it may take quite a while before it’s actually accepted. WordPress 3.5 is still quite far away. So let’s augment the global $_REQUEST array instead. add_action( ‘load-edit.php’, ‘wpse34956_force_excerpt’ ); function wpse34956_force_excerpt() { $_REQUEST[‘mode’] = ‘excerpt’; } This will lock up modes, forcing excerpt mode … Read more