WordPress : WP_Query vs query_posts() vs get_posts() [Differences |Comparison]

WP_Query vs query_posts() vs get_posts()

  • query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. It is inefficient (re-runs SQL queries) and will outright fail in some circumstances (especially often when dealing with posts pagination). Any modern WP code should use more reliable methods, like making use ofpre_get_postshook, for this purpose. TL;DR don’t use query_posts() ever;

  • get_posts() is very similar in usage and accepts same arguments (with some nuances, like different defaults), but returns array of posts, doesn’t modify global variables and is safe to use anywhere;

  • WP_Query class powers both behind the scenes, but you can also create and work with own object of it. Bit more complex, less restrictions, also safe to use anywhere.




For WordPress News Website in local languages, contact me.

For customized web applications, websites using PHP codeigniter, contact me.

Netbeans 7.2, Netbeans 7.3 Autocomplete for CI 2

  1. Create a new directory inside nbproject (I used this since it’s omitted when pushing to prod) with your name of choice, I used “CI_Autocomplete”.
  2. Create a new file with your name of choice, I used “CI_Autocomplete_2.0.php”, and place it inside the newly created folder, “nbproject\CI_Autocomplete”.
  3. Paste the below code inside the new file, “CI_Autocomplete_2.0.php”.


* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property CI_Email $email
* @property CI_Encrypt $encrypt
* @property CI_Exceptions $exceptions
* @property CI_Form_validation $form_validation
* @property CI_Ftp $ftp
* @property CI_Hooks $hooks
* @property CI_Image_lib $image_lib
* @property CI_Input $input
* @property CI_Language $language
* @property CI_Loader $load
* @property CI_Log $log
* @property CI_Model $model
* @property CI_Output $output
* @property CI_Pagination $pagination
* @property CI_Parser $parser
* @property CI_Profiler $profiler
* @property CI_Router $router
* @property CI_Session $session
* @property CI_Sha1 $sha1
* @property CI_Table $table
* @property CI_Trackback $trackback
* @property CI_Typography $typography
* @property CI_Unit_test $unit_test
* @property CI_Upload $upload
* @property CI_URI $uri
* @property CI_User_agent $user_agent
* @property CI_Validation $validation
* @property CI_Xmlrpc $xmlrpc
* @property CI_Xmlrpcs $xmlrpcs
* @property CI_Zip $zip

class CI_Controller {};

* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Config $config
* @property CI_Loader $load
* @property CI_Session $session

class CI_Model {};


Restart your project and autocomplete “should” work.

if not worked, Now go to File > Project Properties (projectname) > PHP Include Path and include the new folder you created above, nbproject\CI_Autocomplete.

NOTE : Need “system” folder of CI in project folder.



Need a Freelance Codeigniter Developer Kerala, India? Contact Mansoorkhan T K

jQuery 2 Released – April 2013

jQuery 2 Released – April 2013

How 2.0 Changed

Here are some highlights of the changes that jQuery 2.0 brings:

No more support for IE 6/7/8: Remember that this can also affect IE9 and even IE10 if they are used in their “Compatibility View” modes that emulate older versions. To prevent these newer IE versions from slipping back into prehistoric modes, we suggest you always use an X-UA-Compatible tag or HTTP header. If you can use the HTTP header it is slightly better for performance because it avoids a potential browser parser restart.

Reduced size: The final 2.0.0 file is 12 percent smaller than the 1.9.1 file, thanks to the elimination of patches that were only needed for IE 6, 7, and 8. We had hoped to remove even more code and increase performance, but older Android/WebKit 2.x browsers are now the weakest link. We’re carefully watching Android 2.x market share to determine when we can cross it off the support list, and don’t expect it to take very long.

Custom builds for even smaller files: This feature has been greatly refined and extended since its debut in jQuery 1.8. You can now exclude combinations of 12 different modules to create a custom version that is even smaller. A new minimal selector engine, basically a thin wrapper around the browser’s querySelectorAll API, lets you shrink the build to less than 10KB when minified and gzipped. See the README for instructions on how to create a custom build, and remember that any plugins you use will also need to stick to the subset you select.

jQuery 1.9 API equivalence: jQuery 2.0 is API-compatible with 1.9, which means that all of the changes documented in thejQuery 1.9 Upgrade Guide have been applied to jQuery 2.0 as well. If you haven’t yet upgraded to jQuery 1.9, you may want to try that first. Be sure to use the jQuery Migrate plugin.

The full record of changes can be found in the changelog below, and in the list of commits on GitHub.

Create image in PHP using GD with different font , size (Using ttf fonts)

It is going to be pretty basic tutorial. I am gonna write the advanced or the other ones in the next tutorials. Here is a simple code in php which creates a image on the fly. This code is so simple,but i have written comment before each line to help you understand the flow of the code.

//creates a image handle
$img = imagecreate( 200, 200 );
//choose a bg color, u can play with the rgb values
$background = imagecolorallocate( $img,232, 0, 135 );
//chooses the text color
$text_colour = imagecolorallocate( $img, 255, 255, 255 );
//sets the thickness/bolness of the line
imagesetthickness ( $img, 3 );
//draws a line  params are (imgres,x1,y1,x2,y2,color)
imageline( $img, 20, 130, 165, 130, $text_colour );
//pulls the value passed in the URL
$text = $_GET['days'];
// place the font file in the same dir level as the php file
$font = 'comic.ttf';
//this function sets the font size, places to the co-ords
imagettftext($img, 100, 0, 11, 120, $text_colour, $font, $text);
//places another text with smaller size
imagettftext($img, 16, 0, 10, 160, $text_colour, $font, 'Small Text');
//alerts the browser abt the type of content i.e. png image
header( 'Content-type: image/png' );
//now creates the image
imagepng( $img );
//destroys used resources
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $img );

jQuery Cycle Plugin [All in one]

jQuery Cycle Plugin [All in one]

The jQuery Cycle Plugin is a slideshow plugin that supports many different types of transition effects. It supports pause-on-hover, auto-stop, auto-fit, before/after callbacks, click triggers and much more. It also supports, but does not require, the Easing Plugin.

The plugin provides a method called cycle which is invoked on a container element. Each child element of the container becomes a “slide”. Options control how and when the slides are transitioned.

The Cycle Plugin provides many options for customizing your slideshow. The default option values can be overridden by passing an option object to the cycle method, by using metadata on the container element, or by redefining the values in your own code.

Freelance web designer & web developer for hire.

Contact details.

Mansoorkhan T K

Freelance web designer & web developer, Kerala, India

WordPress, Codeigniter, Magento, Opencart, Joomla, PHP/MySQL, jQuery, json, Facebook, Twitter, Paypal, PayU, Ukash, Sagepay, Authorize.net

HMVC with Codeigniter

HMVC is an evolution of the MVC pattern used for most web applications today. It came about as an answer to the salability problems apparent within applications which used MVC. The solution presented in the JavaWorld web site, July 2000, proposed that the standard Model, View, and Controller triad become layered into a “hierarchy of parent-child MCV layers“. The image below illustrates how this works:

HMVC structure

Key advantages to implementing the HMVC pattern in your development cycle:

  • Modularization: Reduction of dependencies between the disparate parts of the application.
  • Organization: Having a folder for each of the relevant triads makes for a lighter work load.
  • Reusability: By nature of the design it is easy to reuse nearly every piece of code.
  • Extendibility: Makes the application more extensible without sacrificing ease of maintenance.

These advantages will allow you to get M.O.R.E out of your application with less headaches.

Download and Tutorial : https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

NOTE : Need some adjustments on several parts.