Allow role to delete posts but block him the wp-admin

Assuming you’re talking about a custom user role named “photographer“, I believe something like this should add the delete_posts capability to that role. function add_delete_cap_to_photog_role() { $role = get_role( ‘photographer’ ); $role->add_cap( ‘delete_posts’ ); } add_action( ‘admin_init’, ‘add_delete_cap_to_photog_role’); After adding the caps to the role, to solve the rest you could either keep blockusers_init and … Read more

Add confirmation popup on “Move to Trash”

You can try to admin enqueue this script, with jquery dependency: jQuery( function($) { $(‘.edit-php a.submitdelete, .post-php a.submitdelete’).click( function( event ) { if( ! confirm( ‘Are you sure you want to move the post to trash?’ ) ) { event.preventDefault(); } }); }); where we restrict the conformation on the a.submitdelete clicks to the .edit-php … Read more

Should our pages be posts?

Both pages and posts are identical internally. Pages are posts of type page, and posts are posts of type post. It’s just a column in the posts table that determines the difference. Similarly, items in the media library are posts of type attachment, menu items in a menu are posts of type nav_menu_item, etc etc … Read more

Check if Currently on Static Posts Page

There are two options: // If the current page is the blog posts index, // but is NOT the site front page if ( is_home() && ! is_front_page() ) or // If the current page has the ID of the // page assigned to display the blog posts index if ( is_page( get_option( ‘page_for_posts’ ) … Read more

Remove double space after a period

I cannot offer a JavaScript solution, because I am not sure where exactly this is happening. But … we can hook into wp_insert_post_data and solve this issue in PHP: add_filter( ‘wp_insert_post_data’, ‘t5_strip_double_spaces’, 20 ); function t5_strip_double_spaces( $data ) { $data[‘post_content’] = preg_replace( “~( \x{C2}\x{A0}|\x{C2}\x{A0} )~m”, ‘ ‘, $data[‘post_content’] ); return $data; } As plugin on … Read more

Linking to page with all posts

You have to create a page template with Loop inside. Then create a page “All My Posts” and assign the template you’ve created to it in “Page Attributes” section of “Edit Page” admin page. You can link to this page from the Front Page using get_page function. Function Reference/get page.