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

Delete Associated Media Upon Page Deletion

How about this? It adapts an example on the get_posts() function reference page. function delete_post_media( $post_id ) { $attachments = get_posts( array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => -1, ‘post_status’ => ‘any’, ‘post_parent’ => $post_id ) ); foreach ( $attachments as $attachment ) { if ( false === wp_delete_attachment( $attachment->ID ) ) { // Log failure … Read more

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