How to remove a column from the Posts page

function my_manage_columns( $columns ) { unset($columns[‘date’]); return $columns; } function my_column_init() { add_filter( ‘manage_posts_columns’ , ‘my_manage_columns’ ); } add_action( ‘admin_init’ , ‘my_column_init’ );

How to detect single.php (but not single-portfolio.php)?

You can use the following instead, if (is_singular(‘post’)) { //your code here… } Where by is_singular is the WordPress API conditional function for testing for the existence of a post type. You can also pass an array of post types if you wish. http://codex.wordpress.org/Function_Reference/is_singular

How to get posts published between a date and today?

UPDATE December 23 2014 There is a better method using date_query property of WP_Query class: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-image’ ) ) ), ‘cat’ => ‘-173’, ‘post_status’ => ‘publish’, ‘date_query’ => array( ‘column’ => ‘post_date’, ‘after’ => ‘- 30 days’ … Read more

Appending content with broken in 4.4

UPDATE 21-01-2016 19:35 SA TIME – BUG FOUND!!!!! YEAH!!!!!! I finally found the bug. As you stated in your last update, the failure only happens when $post_content has a <!–nextpage–> tag in the content. I tested it, and did confirm that any other page after the page after the <!–nextpage–> returns a 404 and then … Read more

How to change the case of all post titles to “Title Case”

Updating the posts $all_posts = get_posts( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’ ); foreach ( $all_posts as $single ) { wp_update_post( array( ‘ID’ => $single->ID, ‘post_title’ => to_title_case( $single->post_title ) // see function below )); } Converting a string to “Title Case” And, while not pertinent to WP, for the sake of completeness: function to_title_case( … Read more

How to end the excerpt with a sentence rather than a word?

This requires PHP 5.3+ (WP requires PHP 5.2.4+) add_filter(‘get_the_excerpt’, ‘end_with_sentence’); function end_with_sentence($excerpt) { $allowed_end = array(‘.’, ‘!’, ‘?’, ‘…’); $exc = explode( ‘ ‘, $excerpt ); $found = false; $last=””; while ( ! $found && ! empty($exc) ) { $last = array_pop($exc); $end = strrev( $last ); $found = in_array( $end{0}, $allowed_end ); } return … Read more

Is there a action hook for the “Empty Trash” button?

I don’t think there exist one, but you could create your own, wpse_empty_trash, with something like this: /** * Add a custom hook ‘wpse_empty_trash’ */ add_action( ‘load-edit.php’, function() { add_action( ‘before_delete_post’, function ( $post_id ) { if ( ‘trash’ === get_post_status( $post_id ) && filter_input( INPUT_GET, ‘delete_all’ ) && 1 === did_action( ‘before_delete_post ‘ ) … Read more