How to create a custom query using shortcode

Have you ever tried to create a shortcode which create a custom worpress query?

Try with below code, i suggest the below code if you wish to show any articles/post to anywhere in the site using this shortcode.

You can get content using wordpress shortcode by passing your queries.

if(!function_exists ('custom_query')){
	function custom_query($atts)
		$result = '';
		global $post;
		$query = new wp_query($query_string);
		if($query->have_posts()) {
			while($query->have_posts()) { $query->the_post();
				$result.="<div class='post-item'>
<a href=".get_permalink()."><img width='100' height='100' src=".$meta." /></a>
<h1><a href=".get_permalink().">".get_the_title()."</a></h1>
<p class='metadata'><span class='post'>Posted by:</span>".get_the_author()."<span class='in-cat'>In:</span>".get_the_category_list(', ')."<span class='on-date'>On:</span>".get_comment_time()."<a href=".get_comments_link().">".get_comments_number('1 comment','2 comment','% comment')."</a></p>
<p>".get_the_content()."</p><p><a class='more-link floatright' href=".get_permalink().">Read More</a></p></div>";
		return $result;

You can use the shortcode [custom_query]

Example: [custom_query query_string=’cat=4′].

This will help you to create custom query using shortcode.

How To Make WordPress Theme Multilingual and WooCommerce Compatible

In this article you can learn about how to create a wordpress theme which is perfectly suitable for Woocommerce and WPML.

Before starting i would like to mention some points.

In order to have a multilingual woocommerce website you need to install the following plugins.

Woocommerce By Woothemes –

WPML By OnTheGoSystems,Inc. – (

Woocommerce Multilingual – (

WPML allows you to translate all the standard WordPress elements. This includes:

  • Menus
  • Standard widgets
  • Navigation elements
  • All texts wrapped in `gettext` calls
  • Post content including custom fields and taxonomy
  • Products
  • Theme options
  • Images and strings related to them

In order to have a WPML supported theme, you must follow the below conditions.

Add GetText Functions to Texts

For plugins or themes, be sure to wrap your hard-coded text in `gettext` functions. This includes the header, footer, and widget text. Your template files display an assortment of product information and hard coded text. For example, most templates will include the product name and a ‘buy’ link. The product name comes from the database, so you don’t need to worry about translating it.
Continue Reading…

How to extract zip files from server directly using php

All of servers not providing cpanel/GUI to access the files. Uploading through FTP will be a great deal and it will time consuming if there are number of files. For eg: if we are uploading CMS like WordPress, joomla, magento, there will be no of files (more than 2000+ files).

In this case i would suggest to upload the zip file via ftp and use a php extract method by adding the following code.

$zip = new ZipArchive();
$x = $zip->open('');//your zip file name here
if ($x === true) {
 $zip->extractTo(dirname(__FILE__)); // change this to the correct site path

This will reduce the delay in uploading.

How to get Youtube Subscriber Count Using PHP

You may be facing some situations in wordpress to display the total count of youtube subscribers, you can use the below code for display the youtube subscribers count.

echo $youtube_subscriber_count = json_decode(file_get_contents(''))->entry->{'yt$statistics'}->subscriberCount;

if you are looking for a function, don’t be afraid.

function getYouTubeSubscribers($channel, $stat = 'subscriberCount')
  return json_decode(file_get_contents('' . $channel . '?v=2&alt=json'))->entry->{'yt$statistics'}->$stat;

Total Video Views:
echo getYouTubeVideoViews('anandmahalakshmi');

Magento Hierarchy

Well,before we starting to go with theme development we need to understand the Magento Hierarchy and where our theme falls into place. There are hundreds of folders and thousands of files, so the listing of all items will be impossible, I will only be focusing on the ones we need to work with.



Magento is having two folders which is mainly for theme and appearence. App and Skin which correspond with each other. The app directory contains files that control how the page templates are rendered, the structure. The skin directory contains files that control the appearance of the website such as CSS, JavaScript, and images.

Within a sub-folder of app and skin are where our packages and themes can be found, a typical install of Magento comes with two packages base and default.

Next we can learn about packages.

How to install Joomla on Ubuntu 14.04

Joomla is one of the most popular free content management systems (CMS) in the world that allows you to easily create and manage a dynamic website. This articles is a simple guide on how to install joomla in Ubuntu 14.04 (a well establshed operating system since 2004.).

First of all we should create a database for joomla, Go to MySQL shell first

mysql -u root -p

Create a database using the following command. I just named my database ‘mydatabase’. You can give a name of youe choice.

CREATE USER joomlauser@localhost;
SET PASSWORD FOR joomlauser@localhost= PASSWORD("mypassword");

Giving privileges to the user on Mysql-server.

GRANT ALL PRIVILEGES ON mydatabase.* TO joomlauser@localhost IDENTIFIED BY 'mypassword';

Refresh MySQL:


Exit out of the MySQL shell:


Restart apache and mysql:

service apache2 restart
service mysql restart

We will first make a directory temp, where we can download and temporarily store our Joomla files:
create a directory

mkdir temp

change directory to temp

cd temp

Now we are in the temp directory. We will then download the latest version of joomla(it is joomla 3.3.3 at the time of writing) to this directory.


We need to install unzip as by default it is now installed:

apt-get install unzip

Now create a directory for keep our joomla files( I named it ‘joomla’) in/var/www/html/

mkdir -p /var/www/html/joomla

unzip the Joomla zip file in the newly created folder:

unzip -q -d /var/www/html/joomla

Now give appropriate permissions in the directory

chown -R www-data.www-data /var/www/html/joomla
chmod -R 755 /var/www/html/joomla

Now proceed to the web installation of Joomla.
You can now complete the remaining steps in your browser. Go to the URL http://domain name orIP address/joomla:

Follow the installation steps.

Once you have finished going through the installer, delete the installation folder per Joomla’s instructions and change the permissions on the config file:

sudo rm -rf /var/www/installation/
sudo chmod 755 /var/www/configuration.php

Now you can access the admin panel at http://domain name orIP address/joomla/administrator/ give the credentials as you gave at the time of Joomla installation.

WordPress Recent Users

Yesterday i came up in a situation to show the recently registered users in one of my ongoing projects. I have made this requirement by using below code.

This code can be placed in your function.php of theme.

function recently_registered_users() {
global $wpdb;
$recentusers = '<ul>';
$usernames = $wpdb->get_results("SELECT user_nicename, user_url, user_email FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
foreach ($usernames as $username) {
if (!$username->user_url) :
$recentusers .= '<li>' .get_avatar($username->user_email, 45) .$username->user_nicename."</a></li>";
else :
$recentusers .= '<li>' .get_avatar($username->user_email, 45).'<a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
$recentusers .= '</ul>';
return $recentusers;

After that we need to use the below code for displaying it wherever you required. I have placed the code in my sidebar

<?php recently_registered_users(); ?>

If you wish to have a shortcode for this, it can be simply added by using the below code to the functions.php

add_shortcode('recentusers', 'recently_registered_users');

By adding this shortcode you can use the functionlaty where ever you need. Like in post, pages etc.

You may need to use the bellow shortcode for display the newly registered users in post, pages or widget.


By adding this you can show your recently registered WordPress users in your sidebar or post or pages.

Hope this help some one…..!!!!!

Building a Single Page Website Using WordPress

Hey Friends,

Here i am going to give you some tips to make a single page website, Nowadays single page website becomes trending. So this may help some one who are trying to make a one page website.

I am going to give an idea of building a single page website having 3-4 sections using wordpress. Continue Reading…

Facebook Like Box

The Facebook Like Box is a social plugin that enables Facebook Page owners to attract and gain Likes from their own website. Greenlemon facebook like box display fan page posts, like button, and connections on your website using widget or shortcode. Enjoy my first plugin experience with wordpress.

Continue Reading…

Showing Joomla Module positions on Front End

ospositions is a simple plugin that reveals you the position of the modules on your site to the users.

How it Works:

You can download it from here 

Install the downloaded file from the extension manager.

Continue Reading…