get_categories() returns “Uncategorised”

It seems like there was some kind of problem with my multisite setup which caused WordPress to fetch the categories from some other blogs posts. (Can’t really tell where from actually). However by writing switch_to_blog(1) (which it always will be) it seemed to work as it should.

Show popular post by category code

You are running two queries in one. You should only run one, and definitely not with query_posts. You should never ever use query_posts Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic … Read more

Listing Texts of Which Custom Field is Null

Don’t let the fields be set to null or unset altogether. The queries needed to get that data are not efficient. Set your field to “no” or some other value. function save_details(){ global $post; if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) { return $post->ID; } $valid = array( ‘yes’ => ‘yes’, ‘no’ => ‘no’ ); if ( isset … Read more