How to get current_cat in navbar, in single post

I found the answer here. Add to functions.php the following function and hook: function sgr_show_current_cat_on_single($output) { global $post; if( is_single() ) { $categories = wp_get_post_categories($post->ID); foreach( $categories as $catid ) { $cat = get_category($catid); // Find cat-item-ID in the string if(preg_match(‘#cat-item-‘ . $cat->cat_ID . ‘#’, $output)) { $output = str_replace(‘cat-item-‘.$cat->cat_ID, ‘cat-item-‘.$cat->cat_ID . ‘ current-cat’, $output); … Read more

Custom Search Query

1) You can use the template search.php and searchform.php as your starting points. Creating a Search Page Codex 2) As far as the custom query goes, you can use pre_get_posts hook to test if you’re on a search page, then you get $_GET your values, edit your query accordingly. Action Reference – pre_get_posts There are … Read more

Scaling a WP eCommerce site

I’ve developed a 55k product ecommerce site using WordPress with the Shopp plugin and can share what I’ve done to MySQL to eke out better performance, YMMV and some (or all) of these may not apply to your situation. Determine how much you need to increase buffers/caches by by looking at the output from a … Read more

get_pages() not ordering as it should

This is indeed an error, and probably caused by the child_of argument. Because child_of requests the whole subtree of the given page (not only the direct children, but also children of those children and so on), WordPress first queries for all the pages and then selects a subset of those pages. The first query respects … Read more