is_home() || is_front_page() not working ! [solved]

There are some situations when the WP conditional tags doesn’t work. Be it any reason like say: Multiple WordPress loops, faulty use of query_posts(…) or issue in the code itself. Basically this problem occurs when there is a change in the main query by the use of query_posts(). Fortunately WordPress always keeps the original, unaltered query intact. So, to get back that where all the conditional tags works we have to use the wp_reset_query().

Just place this function call wp_reset_query() before the conditional tag to solve this issue of WordPress’s is_home() || is_front_page() is not working.

Sample Code:
<?php wp_reset_query(); ?>
<?php if(is_home() || is_front_page()): ?>
     <! Do the things here... >
<?php else: ?>
     <! Else part goes here...  >
<?php endif;  ?>


10 Ways to Search Google for Information That most People Don’t Know About

In our era of advanced technology and high-speed Internet connections, you can find information on virtually anything. In the space of just a few minutes, we can find recipes for the tastiest pie or learn all about the theory of wave-particle duality.

But more often than not, we have to sift through a vast body of knowledge to get the information we need, and this can take hours rather than minutes. These are the most effective methods for searching Google to help you find the precious material you’re looking for in just a couple of clicks.

  1. Either this or that

Sometimes we’re not sure that we’ve correctly remembered the information or the name we need to start our search. But this doesn’t have to be a problem! Simply put in a few potential variations of what you’re looking for, and separate them by typing the “|“ symbol. Instead of this symbol you can also use ”or.” Then it’s easy enough to choose the result that makes the most sense.


  1. Searching using synonyms

Our language is rich in synonyms. Sometimes this can be very convenient when doing research online. If you need to find websites on a given subject rather than those that include a specific phrase, add the “~” symbol to your search.

For example, if you search for the term “healthy ~food” you’ll get results about the principles of healthy eating, cooking recipes, as well as healthy dining options.

Searching using synonyms

  1. Searching within websites

Sometimes you read an interesting article on a website and find yourself subsequently wanting to share it with your friends or simply reread it. The easiest way to find the desired piece of information again is to search within the website. To do this, type the address of the site, then a key word or entire phrase from the article, and it should come up immediately.

Searching within websites

  1. The power of the asterisk

When our cunning memory decides to prevent us from recalling that one key word, phrase, or number we need in order to find what we’re looking for, you can turn to the powerful “*” symbol. Just use this in the place of the word/phrase you can’t remember, and you should be able to find the results you’re looking for.

The power of the asterisk

  1. When lots of words are missing

If it’s the lengthier half of the phrase you can’t remember rather than a single key word, try writing out the first and last words and putting “AROUND + (the approximate number of missing words)“ between them. For example, ”I wandered AROUND(4) cloud.”

When lots of words are missing

  1. Using a time frame

Sometimes we urgently need to acquaint ourselves with events that occurred during a certain period of time. To do so, you can add a time frame to your search query with the help of three dots between the dates. For example, if we want to find out about scientific discoveries during the 20th century, we can write:

Using a time frame

  1. Searching for a title or URL

To help find the key words and name of an article, type “intitle:“ before the search term, without any spaces between them. In order to find the words from a URL, use ”inurl:”.

Searching for a title or URL

  1. Finding similar websites

If you’ve found something you really like online and want to find similar websites, type in “related:” and then the address of the site, again without a space between them.

Finding similar websites

  1. Whole phrases

Framing the search term within quotation marks is the simplest and most effective way to find something specific and in the exact order you typed it in.

For example, if you type in the words I’m picking up good vibrations without quotation marks, the search engine will show the results where these words appear in any order on a website, as opposed to the specific order in which you typed them.

If, on the other hand, you type “I’m picking up good vibrations” within quotation marks, you’ll get only those results where these words appear only in the order you typed them in. This is a great way to find the lyrics to a song when you only know one line from it.

Whole phrases

  1. Unimportant search words

To remove unimportant search words from your query, simply write a minus symbol before each one. For example, if you want to find a site about interesting books, but you aren’t looking to buy them, you can write the following:

Unimportant search words

Paypal PDT (Sample code for validating transaction when auto return from Paypal)

This post is continue of my previous post:
» Auto Return users from Paypal on successful payment and introduction to PDT

In previous post, we have successfully completed setting up the Paypal Auto Return and Payment Data Transfer (PDT) features on Paypal. In this post, we will be adding up transaction validation code to our return url so that, we can finally give access to the users into our members area.

Below I am listing the whole process being followed from when the user clicks buy now button to when they are given access to members area.

  • First of all, user clicks on the buy now button and is taken to the paypal for payment. Paypal displays the lists of available methods of payment so that user can pay for the item they want to purchase.
  • After successful payment, user is redirected to the return URL setup in Paypal, with certain parameters appended to the URL. If you haven’t setup/enable the Paypal Auto Return and Payment Data Transfer option in your Paypal Business Account, then click here to read my previous post on Auto Return users from Paypal on successful payment and introduction to PDT
  • Return URL is where we have the transaction validation code. As paypal redirects the user with certain parameters, as tx=, amount, quantity, etc. our script, would validate these locally and then send a request to Paypal for confirmation. While requesting paypal, we will need PDT Identity Token from paypal to verify which I am going to explain in more details below.
  • As the request is send to Paypal, Paypal verifies the request and responds back with the complete transaction details. Transaction details consists of each and every attributes which we need to validate again with our script to avoid fraudulent transactions.
  • Once validation succeeds, we can show user with success message, create member and redirect them to members area, or anything the payment was made for.

Paypal PDT Identity Token

Paypal PDT Token is an access token that uniquely identifies your account. Like any other access token, this is required to request Paypal for any transaction details within your account, and to prevent any non authenticated users from requesting the details.

If you have gone through my previous post, you might have already known how this token is generated. On Website Payment Preferences page, after you enable Auto Return and Payment Data Transfer and click save, you will be redirected to My Profile page with a message as on screenshot below:

which displays the PDT Identity token. You can access this token anytime from your PDT section on Website Payment Preference page.

Below, is the sample code in PHP for validating transaction using this PDT identity token:

Sample code in PHP for Paypal PDT Transaction Validation

Once payment is successful, user is redirected to Return URL with certain parameters appended to the URL with transaction id. Grab this transaction id from URL and validate transaction by communicating with Paypal and execute script to process order.

// defining some constants
define("USE_SANDBOX", 1);
define("PDT_TOKEN", "your PDT Identity Token");
define("VERIFY_EMAIL", 'Your email for Business Paypal');
define("VERIFY_CURRENCY", 'Currency to be verified');
define("VERIFY_AMOUNT", 'Amount to be verified');

function alreadyExist($txid){
	// check if this transaction id has already been processed	

function processOrder(){
	// process the Order
	// create member or get users access to item what they had paid for	
if(isset($_GET['tx']) &amp;&amp; ($_GET['tx'])!=null &amp;&amp; ($_GET['tx'])!= "") {
	$txn_id = $GET['tx'];
	$request = 'cmd=_notify-synch';
	$auth_token = PDT_TOKEN;
	$request .= "&amp;tx=$txn_id&amp;at=$auth_token";
	// post back to PayPal system to validate
	$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
	$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
	$header .= "Host:\r\n";
	$header .= "Content-Length: " . strlen($request) . "\r\n";
	$header .= "Connection: close\r\n\r\n";
	if(USE_SANDBOX == true)
		$fp = fsockopen ('ssl://', 443, $errno, $errstr, 30); 
		$fp = fsockopen ('ssl://', 443, $errno, $errstr, 30);
	if (isset($fp) &amp;&amp; $fp) {
		fputs ($fp, $header . $req);
		// read the body data
		$res = '';
		$headerdone = false;
		while (!feof($fp)) {
			$line = fgets ($fp, 1024);
			if (strcmp($line, "\r\n") == 0) {
				// read the header
				$headerdone = true;
			else if ($headerdone) {
				// header has been read. now read the contents
				$res .= $line;
		// parse the data
		$lines = explode("\n", $res);
		$response = array();
		if (strcmp ($lines[1], "SUCCESS") == 0) {
			for ($i=1; $i&lt;count($lines);$i++){
				list($key,$val) = explode("=", $lines[$i]);
				$response[urldecode($key)] = urldecode($val);
			$itemName = $response["item_name"];
			$amount = $response["payment_gross"];
			$email = $response["receiver_email"];
			$userEmailPaypalId = $response["payer_email"];
			$paymentStatus = $response["payment_status"];
			$TxId = $response["txn_id"];
			$currency = $response["mc_currency"];
			// check the payment_status is Completed, receiver email is your paypal account, currency and amount are correct
			if($paymentStatus=="Completed" &amp;&amp; $email == VERIFY_EMAIL &amp;&amp; $currency == VERIFY_CURRENCY &amp;&amp; $amount == VERIFY_AMOUNT) {
				// check that txn_id has not been previously processed			
					// process the order
	fclose ($fp);
} else {
    // Display appropriate error message

Auto Return users from Paypal on successful payment and introduction to PDT

On my recent project, I was suppose to give my users access to the members area as soon as they complete the payment. I was using Paypal as the mode of the payment as this is the most widely used and is available for most of the countries.

By default, user is presented with the buy now button, which takes them to paypal for the payment and on successful payment, users are presented with options as shown in image below, where users need to click on the link to get back to our webpage.

My requirement was different, I was suppose to get buyers back to my website after they complete the payment process automatically and validate transaction to create a member and log in successfully, displaying them their dashboard page with thank you message and a summary of their payment. Paypal provides us with the Auto Return and Payment Data Transfer(PDT) features for this purpose. Below, I have listed out the steps to enable the Paypal auto return and PDT:

  • Login to your Paypal Business Account.
  • Navigate to “My Selling Tools” under Profile menu. Refer to screenshot below:
  • Under Selling online category, locate “Website preferences” and click on “Update” button showing next to it. Refer to screenshot below:
  • You will be presented with the Website preferences page with Auto Return, Return URL, PDT and other options as below:
  • Select “on” for the Auto Return and Payment Data Transfer radio button. For Return URL, you need to mention the link to your webpage, where you wish to redirect your buyers or where the whole processing after the payment takes place. Refer to 3 red boxes above in the screenshot.
  • Scroll to the bottom of the page and click on the Save button to Save the settings. Once saved you will be presented with the Identity token at the bottom of “Payment Data Transfer” section. You will need this token to access and call Paypal servers to validate transactions.

These steps, ensures that you successfully completed setting up Paypal Auto Return and Payment Data Transfer feature on Paypal Business Account. Next step is to add the transaction validation code to the Return URL we just saved. I will cover this up on my next article, explaining details on setting up Paypal PDT with sample code.