Sort registered users by post count? (inside admin dashboard)

Try the following code: add_filter(‘manage_users_sortable_columns’, ‘my_user_sortable_columns’); function my_user_sortable_columns($sortable_columns) { $sortable_columns[‘posts’] = ‘post_count’; return $sortable_columns; } Credit to: Add additional user fields and make them sortable in the user screen

how to echo all tables that start with a prefix

You could try changing the output type of get_results() to ARRAY_A or ARRAY_N and see what kind of array they give you. E.g. $tables = $wpdb->get_results(“show tables like ‘pro_hist%'”, ARRAY_A); var_dump($tables); foreach( $tables as $table ) { var_dump($table); } If $table is an array and it has the name as the first value, then get … Read more

wrong php date()?

This could probably make exquisite debugging session, but taking in account it’s Friday evening – just use date_i18n() instead and let WordPress deal with a huge mess that time/date issues usually are.

How to create post thumbnail

IF you want to retrieve thumbnail in size that you had set with set_post_thumbnail_size() then call the_post_thumbnail() without passing any arguments. That will default to named post-thumbnail size that that set_post_thumbnail_size() actually creates. Also crop for this will be determined by third argument in set_post_thumbnail_size() (defaults to false) and is not tied to media settings … Read more

SetCookie simply not working

Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here’s how you can test that: function set_cookie() { var_dump(headers_sent()); // should be bool(false) … Turning WP_DEBUG on in your config.php file may help also while debugging. By the way, you really should be doing some filtering … Read more

Theme currently showing thumbnails, how to show full size?

Here is the relevant code from home.php (the Blog Posts Index): <?php if($grisaillePostCount == 1) { the_post_thumbnail(); } else { the_post_thumbnail(‘following-post-thumbnails’); } ?> Here is the relevant code from index.php: <?php the_post_thumbnail(‘following-post-thumbnails’); ?> So, the difference is the default thumbnail size, and the custom ‘following-post-thumbnails’ image size. In functions.php, the Theme defines the defualt ‘thumbnail’ … Read more

Memory errors with media upload, WordPress can’t use more than 96M (while there’s 512 available!)

You’re looking at the problem the wrong way. The error you’re seeing isn’t an error coming from WordPress, it’s a PHP error. Somehow, somewhere, something is limiting the memory limit to 96M, and it ain’t WordPress that’s doing it. Here’s the thing: WordPress can’t actually limit the memory on most servers. I know that it … Read more

is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’

Here’s something I wrote because my clients were using very high quality pngs, when they could be more lossy jpgs for web. Note this still preserves the original image, only changes the thumbnails. Add this to your functions.php <?php //Force PNG Thumbnails into JPGs add_filter(‘wp_generate_attachment_metadata’,’force_png_to_jpg’); function force_png_to_jpg($image_data) { $sizes = array(‘thumbnail’,’medium’,’large’); $upload_dir = wp_upload_dir(); $file … Read more