[Login-with-AJAX issue solved] – Logout user when browser is closed

After installing a plugin “Login With AJAX”(version 3.0.4 or less), I faced a issue with wordpress logout. The issue was:

The user is kept logged-in even after the browser is closed !! The user needs to logout explicitly from the site.

In general, browser clears the cookies(Session Cookies) set by WordPress for the logged-in user when the browser is closed, but the way “login-with-ajax” submits the login-form data, it always set the “remember me” value to something(long time in future) which makes the cookie as persistent. So the cookie never expires and user is kept logged-in always evenif browser is closed.

Follow the steps below for a quick fix to the above problem:

  • – Read the section “Customizing the Widget” here so that we can change a cor plugin file.
  • – Open the file “login-with-ajax.source.js” inside the widget directory and copy the whole code inside it, then paste the code into the file “login-with-ajax.js” and save. We are doing this to have un-minified version of code, for ease of editing. ๐Ÿ™‚
  • – Search the function “getPostData” and add the below lines after el = $(el);
  • – Code after changing, looks like below:
  • – Save and check. ๐Ÿ™‚ Now, after browser close, it should be logging out the wordpress user

Facebook jQuery PHP WordPress

Loading facebook social plugin into AJAX generated dynamic content. [Solved]

To include Facebook social plugins(ex: Facebook Comments into our site, we use some java-script and some HTML structure provided by facebook. It works fine until you have AJAXified your pages. If your site refreshes each page on each request then facebook social plugins work perfect.
Problem occurs when the HTML structure is loaded via AJAX and the script used for FB is not called again after the ajax response. This happens because Facebook parses the page only on initial load and so doesn’t pick up the dynamic content. To make it work on AJAXified content, we need to explicitly tell it to re-parse the entire page, or just the new content.

Recently, I used a plugin called “Ajaxify WordPress Site” which makes a wordpress website completly AJAXified semlessly. Really nice plugin to ajaxify WP sites without any hassel, but one problem I faced with this was Facebook Comments not being rendered after AJAX response for which the answer is “FB.XFBML.parse()” function call.


1. JavaScript SDK which needs to be included once on the page.

2. HTML code to be placed wherever we want facebook plugin to appear on your page.

So, in our case, say this bit of HTML code comes dynamically with AJAX not on page refresh. So how can we display the facebook comments ?

Answer is simple: Call the ” FB.XFBML.parse() ” explicitly inside the AJAX success function, which will re-parse the html and render the Facebook comments section. ๐Ÿ™‚

3. Code for AJAX success block with “FB.XFBML.parse()” call.

Hope this will help someone solving facebook social plugin issue with AJAX content.. ๐Ÿ™‚


List of parameters that can be pass through WP_Query constructor to create a new query object in wordpress

WP_Query – the heart of wordpress is nothing but a class defined to fetch data from DB and make global objects that can be used in wordpress.
To create a new wordpress query object we can pass the parameters accordingly and get the required data. Here is a list of parameters with description in one place which can be passed through the WP_Query constructor.




WordPress 3.4 upgradation creates new problems, issues !!

Now that WordPress 3.4 Green is out, everybody can see a upgrade notification on the top of admin backend. Before clicking that link for auto update, let’s see some of the problems, bugs, issues those are reported by users who has already upgraded.

If you Google a bit, you can find that: wordpress 3.4

  • Header problems after Upgrade to WP 3.4 and Weaver 1.1
  • WordPress 3.4 – Image align problem
  • Trying to troubleshot image caption issue
  • Incompatibility with qTranslate plugin
  • WordPress upgrade 3.4 and now no Akismet stats
  • WP upgrade 3.4 broke my page templates
  • WordPress 3.4 Upgrade Error with Database Reloaded Plugin
  • SleekPhoto Slider Not Working After WordPress 3.4 update
  • Can’t login after upgrade WP 3.4
  • Mail problem After wp 3.4

And lot more like these…..

Is the new WordPress Green has Bugs,defects ??(Ans: may be , may be not) Why is it breaking my site’s design, site’s functionalities ??

So the answer to all these above problems is precautions and backups before upgrading the WordPress to latest. WordPress always warns you to โ€œplease back up your database and filesโ€ before upgrading to the latest version of WordPress. Out of 100%, let’s say.. 1% or less is the chance that the new WP version might have problems, others are due to incompatibility with plugins and themes.

Remember these points before upgrading to newer version of WordPress.

WordPress Before Upgrade Checklist:

1- Check your Theme and Plugins for compatibility with WordPress 3.4

Try to ensure that your current theme and plugins are compatible with the newer version of WordPress. Visit these links to check Theme Compatibility and Plugins Compatibility. If the theme and plugins are not compatible, then update to latest versions of Theme and Plugins.

2- Disable and/or Remove Old Plugins:

Go through your Plugins list and get rid of the Plugins you donโ€™t use any more. Remove them from your server. If there are Plugins which are not compatible with the new version, check for updates and install them. If there are no updates, look for alternatives.

3- Validate your Theme:

If you have been tweaking with your WordPress Theme, take time to run it through a validator to ensure that it still works and there is nothing left broken. See the Validating a Website article in the WordPress Codex for help.

4- Take Backup of everything:

  • Backup your database using tools like PhpMyAdmin, Adminer etc.. Several plugins can be used to backup: WP DB Manager , X-Cloner Backup
  • Back up ALL of your files in your WordPress directory and your .htaccess file. Typically, this process involves using an FTP program to download ALL your WordPress files from your host to your local computer. Use  BackWPUp plugin to backup your whole site.
  • Ensure that the backups are usable and kept in a safe,secure place.
  • Never Delete these files:

    • wp-config.php file;
    • wp-content folder; Special Exception: the wp-content/cache and the wp-content/plugins/widgets folders should be deleted.
    • wp-images folder;
    • wp-includes/languages/ folder — if you are using a language file do not delete that folder;
    • .htaccess file — if you have added custom rules to your .htaccess, do not delete it;
    • robots.txt file–if your blog lives in the root of your site (ie. the blog is the site) and you have created such a file, do not delete it.

5- Now, if everything is in place, go and upgrade wordpress to version 3.4 Green.

Check the whole site if everything is working fine. ๐Ÿ™‚ However, this does not mean everything is guaranteed to go smoothly. Even if most of the sites experience no issues with an upgrade, there is always some sites that can experience small problems.

For troubleshooting

, check your theme files, plugins files.

  • Try disabling the current theme and enable TwentyEleven theme.
  • Disable plugins and enable one by one to check which plugin is causing issue.
  • Visit respective plugin support forums on WordPress website. WordPress Support Forum

    Latest news !! WordPress 3.4.1 is out with lots of fixes and patches

    On June 27, 2012, WordPress 3.4.1 was released to the public. This is a maintenance and security update.

    This maintenance release addresses 18 bugs with version 3.4, including:

    • Fixes an issue where a themeโ€™s page templates were sometimes not detected.
    • Addresses problems with some category permalink structures.
    • Better handling for plugins or themes loading JavaScript incorrectly.
    • Adds early support for uploading images on iOS 6 devices.
    • Allows for a technique commonly used by plugins to detect a network-wide activation.
    • Better compatibility with servers running certain versions of PHP (5.2.4, 5.4) or with uncommon setups (safe mode, open_basedir), which had caused warnings or in some cases prevented emails from being sent.

    Additionally: Version 3.4.1 fixes a few security issues and contains some security hardening. These issues were discovered and fixed by the WordPress security team:

    • Privilege Escalation/XSS. Critical. Administrators and editors in multisite were accidentally allowed to use unfiltered_html for 3.4.0.
    • CSRF. Additional CSRF protection in the customizer.
    • Information Disclosure: Disclosure of post contents to authors and contributors (such as private or draft posts).
    • Hardening: Deprecate wp_explain_nonce(), which could reveal unnecessary information.
    • Hardening: Require a child theme to be activated with its intended parent only.



How to display wordpress posts sorted by post view count [Solved: without a plugin]

Several plugins are there which displays the posts according to number views( number of times the post is viewed). We can achieve the same thing without using a plugin. We can use this code in a particular WordPress theme files. Also it’s very easy to sort the posts according to the post views. Even, we can use the view count to display it side to each post.


  1. Paste the code below into your current theme’s function.php file. Try to use child theme if you are not already having one.(Child theme is optional though)
  2. Open single.php file which is responsible to display each post in WordPress and paste this single line of code inside the loop
  3. You can display the post view count by using this line of code inside the WordPress loop on any page.
  4. We can display posts sorted by Post view counts by using the code below.

WordPress plugins for post view counts are good but those provide extra functionalities which are not really needed for most of the cases; so why to bloat the setup and add to the response load of the website. Fastness of website matters !! ๐Ÿ™‚


[Solved] latin1_swedish_ci collation by default in PhpMyadmin to “utf8_general_ci”

After upgrading to PhpMyAdmin version: 3.4.5 (which comes in XAMPP 1.7.7-VC9), I noticed that the default collation of MySql is set to “latin1_swedish_ci”.Due to this, whenever a new database is created using phpMyAdmin, it sets the collation as latin1_swedish_ci by default(there will be no problem due this though). We can change this to “utf8_general_ci” / “utf8_unicode_ci” by selecting the needed one before creating the database. If we forgot to select the right one, then it will make the collation as “latin1_swedish_ci”. ๐Ÿ™

Change the default collation to utf8_general_ci in MySql:

  • Open the my.ini file. (C:xamppmysqlbinmy.ini)
  • Find the text [mysqld] and add the below lines.

    The above two lines will select a character set and collation at server startup. These settings apply server-wide and apply as the defaults for databases created by any application, and for tables created in those databases.
  • Save the file and restart the mysql server.(XAMPP Control Panel -> Stop -> Start)

For more info read: Configuring the Character Set and Collation for Applications


Remove or override functions attached to a specified filter hook

There are situations when a plugin/theme use some filter hooks to change the default behaviour of the wordpress functionality and then forgets to remove the change they have applied or sometimes intentionaly because of such requirement. But this affects all over the website and causes problem, where as we want to use the default behaviour and not this changed one.

Now, the question is ” how can we override a funtion that is already applied for a particular filter hook “.

Option 1: remove_filter

If we know which function is called for a particular hook which is causing the issue, then we can use

Option 2: remove_all_filters

Remove all the call_back functions those are added for a particular filter hook.(Helpfull when we don’t know the functions that are applied for a particular filter)

But again,this might cause issues as we are completly removing all the functions(whatever is the priority) for that filter hook. There is a solution too.

Option 3: add_filter with high priority

Call a custom defined function with high priority for the filter hook.
Default priority number is 10. So I am passing 99 as the $priority parameter.

Don’t forget to remove the filter once you are done with your task.


Simple example to understand the exact situation:

* A plugin uses a function to change the default sorting order of posts.

* Now we have a widget(say Popular Posts by Comments count) which fetches and displays the most commented posts.

* Now the problem is that the Popular Posts by Comments count widget does not display the posts as intended i.e. orderby most commented. ๐Ÿ™


Write a function which will be called to override the previous funtion(mentioned above). Now call this function for that filter hook with high priority. ๐Ÿ™‚

* So the modified code will be as below:

Hope this post will help somebody someday !! ๐Ÿ™‚



Wordcamp 2012 at Cuttack, Odisha

WordCamp Cuttack, Odisha, India, where enthusiasts will discuss development (core, plugins, themes), business models, the art of blogging and other matters related to WordPress. It also going to feature a workshop, designed for WordPress newbies, who have little or no knowledge of WordPress. This is the opportunity to learn from highly acclaimed WordPress geeks. So what are you waiting for…!!

Find some details here:

WP E-Commerce

Category wise products display in WP E-Commerce products page

WP E-Commerce displays all the products from all the categories in the default products page which uses the template file: wpsc-products_page.php for displaying. There are situations when we have product categories, under each category we have different products. Now we have to display all the products grouped by product-categories. Like:


We can achieve this using short-codes provided by wp e-commerce, but then we have to write the shortcode that many number of times as we have number of categories.

Find a complete list of wp e-commerce category shortcodes with additional arguments
There are some other problems like: we have to create another product page,write the short codes there and keep the default products page intact, else chances are there that the single product page, category page etc. may break or show page not found error.

So another option is to change the default products-page template file( wpsc-products_page.php ) to display products group by categories. This can be done by running multiple loops in the the products page template file. I have used this once and works fine for me. Use this if it suits your requirement. ๐Ÿ™‚


— Open the wpsc-products_page.php file.
— Find the products loop statement in the code.

— Find the products loop end statement.

— Copy the whole block in between while and endwhile for the product loop.
— Then enclose those copied code inside the below mentioned condition.
— Save and check the products page.

Example Code:


Download the modified wpsc-products_page.php !!


jQuery PHP Social Life Software Tricks Technology

How to display profile image in google search

May be you want to display your google profile image next to the search result for your blogs in Google search. If you google something, you can see some small images next to the search results. These are nothing but the google profile images of the blog authors. When you see that photo show up in your search results, it means Google are verifying that the blog post was written by that person. If you click on the name in the search results, it takes you to that blog author’s Google+ Profile. You can join me on Google+ here!

Thankfully its very easy to configure your site to be compatible with the new author photo snippets that show up on Google Search. However not guaranteed that your photo, or a photo of one of your authors, will appear in Google Search immediately. It is rumored that Google has enabled that feature only for selected blogs and sites based on some criterias.

How to do it ?

  1. Create an author page or “About Me” page on your blog site(same domain).
  2. Add link to this author page from your blogs.
  3. Add a link to your Google profile in the Author page.
  4. Linking Back from Google Profile to your Author page/About Page.Here we need to link back from the Google profile to the about page on the website. Open your Google Profile, click the Profile icon at the top and then the Edit Profile button at the top. Locate links on the right side and select the Add custom link option.

The idea is actually extremely simple. You link from your blog to your Google Profile โ€“ Then, from your Google Profile to your blog. This reciprocal linking verifies that the owner of that Google Profile is also the (or an) author on that blog. If you own a multi authored blog it works too. You just need your bloggers to link from their Google Profile, to their author page on your blog.

Iโ€™d like you to read the instructions from Google,Google: Adding author information in search results which I followed to add the profile image.

To summarize:
Option 1. Add your name and email to your content (recommended for sites with content by multiple authors)
Option 2. Link your content to your Google Profile, and vice versa

Testing with google’s Rich Snippets Tool:
Once you have followed the instructions, check that you have done it correctly using Googleโ€™s Rich Snippets Testing Tool. This tool will let you know if the code is working and show you what your blog will โ€œlookโ€ like in Googleโ€™s search results, AFTER they have activated it. To use the Rich Snippets Testing Tool, simply paste the URL (address) of one of your blog posts into it and press the preview button .

Then, if everything looks OK and you see your photo in the preview, itโ€™s a matter of waitingโ€ฆ I look forward to seeing your smiling faces when Iโ€™m next searching!