Alter $WP_Query in WordPress

When showing list of content (i.e. Posts, Custom Post Type) on Category Page, the main $WP_Query renders posts of default Posts type. To show content from different post type we've to alter the main $WP_Query.

There are few different ways using which we can alter the $WP_Query. But here is one of the way to alter $WP_Query without removing existing conditions in Query.

How to get views result count programmatically - Drupal 7

The current project I'm working on has a lot of customization of Drupal Commerce and display of views. One of the customization I've done is while displaying views result, show total of two views results in one view i.e. there are two views viewA and viewB shown on page, which shares the output and so we need to show the sum of total results in viewA and viewB will be displayed in viewA header.

Here's how I've achieved this with only few lines of code:

Tweak exposed form in Views in Drupal

Views module provides the ability to site admin to allow users to select the filters and dynamically refine the results based on selection made. This can be achieved using exposed filters in views. By default the exposed form looks like normal form i.e. fields to select filter, Apply button to get refined results, etc.

Using views UI, we can tweak exposed form and do following things, without writing a single line of code:

How to setup Virtual Hosts in WAMP

Starting with WAMP, it allows developers to setup site in their local machine just like we setup on dev or production server. I've installed WAMP in my "C:\" drive. After installing WAMP, we get a directory called "C:\wamp\www" which we can directly access using "http://localhost" and any files and directory inside it by appending that to localhost. Suppose I've example as a directory in my "C:\wamp\www" directory so I can access it using my web-browser directly with "http://localhost/example".