Convert ‘ASCII’ character to ‘Normal’ character

Please note that iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, …) doesn’t work properly when locale category LC_CTYPE is set to C or POSIX. You must choose another locale otherwise all non-ASCII characters will be replaced with question marks. This is at least true with glibc 2.5.

iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, “Žluťoučký kůň\n”);
// ?lu?ou?k? k??

setlocale(LC_CTYPE, ‘cs_CZ’);
iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, “Žluťoučký kůň\n”);
// Zlutoucky kun

create canonical page link using WPPaginate class in wordpress

* Author: Yogesh Nayi
* Description: create canonical page link using WPPaginate class in wordpress.
if ( !class_exists( ‘CreateCanonical’ ) ) {

class CreateCanonical extends WPPaginate {

public function canonical_page_url() {
if ($this->type === ‘comments’ && !get_option(‘page_comments’))

$r = wp_parse_args($args, $this->options);
extract($r, EXTR_SKIP);

if (!isset($page) && !isset($pages)) {
global $wp_query;

if ($this->type === ‘posts’) {
$page = get_query_var(‘paged’);
$posts_per_page = intval(get_query_var(‘posts_per_page’));
$pages = intval(ceil($wp_query->found_posts / $posts_per_page));
else {
$page = get_query_var(‘cpage’);
$comments_per_page = get_option(‘comments_per_page’);
$pages = get_comment_pages_count();
$page = !empty($page) ? intval($page) : 1;

$prevlink = ($this->type === ‘posts’)
? esc_url(get_pagenum_link($page – 1))
: get_comments_pagenum_link($page – 1);
$nextlink = ($this->type === ‘posts’)
? esc_url(get_pagenum_link($page + 1))
: get_comments_pagenum_link($page + 1);

$prev = ”;
$next = ”;
$str = ”;
if ($pages > 1) {
if ($page > 1 && !empty($previouspage)) {
$prev = “<link rel=’prev’ href='{$prevlink}’>”;
if ($page < $pages && !empty($nextpage)) {
$next = “<link rel=’next’ href='{$nextlink}’>”;

echo $str = $prev . $next;

}//CreateCanonical end

global $CreateCanonical;
$CreateCanonical = new CreateCanonical();

Note : WPPaginate class is  a pagination class, so when to use pagination plugin is working as well fine.
Refer link (

check on post or page in attachment exist

* Author: Yogesh Nayi
* Description: this function used to check on post or page in attachment exist.
function check_is_attachments_exist(){
global $post;
$attachments = get_children( array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’) );

if ( $attachments ) {
if ( have_posts() ) : while ( have_posts() ) : the_post();

$args = array(
‘post_type’ => ‘attachment’,
‘numberposts’ => -1,
‘post_status’ => null,
‘post_parent’ => $post->ID

$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo wp_get_attachment_image( $attachment->ID, ‘full’ );
echo apply_filters( ‘the_title’, $attachment->post_title );
endwhile; endif;

echo “No-attachments-image”;

Diffrent between MySQL & NoSQL

First of all MySQL is a Relational Database product using SQL from Oracle while noSQL is not a product. It’s a (set of) type(s) of “products” or better phrase as a concept. As the name suggests it’s not SQL. NoSQL types and products are for example:

  • key-value stores like Redis, Tokio Cabinet or even Memcache can be mentioned
  • document database like MongoDb and CouchDB
  • graph databases like OrientDB
  • columnar datastores like Hadoop, Cassandra or Bigtable

SQL means Structured Query Language and this is related to how the data can be retrieved. This is not equivalent with Relational Databases. You can find noSQL RDBMS products as well.

Let me put it this way SQL is a language which can be used for data retrieval in relational databases (for example: MySQL, Postgres, Oracle) just like it can be used (however rarely used) in other types of databases/datastores.

What is NoSQL, and why do you need it?

  • NoSQL is a whole new way of thinking about a database. Though NoSQL is not a relational database, the reality is that a relational database model may not be the best solution for all situations.
  • NoSQL is a whole new way of thinking about a database. NoSQL is not a relational database. The reality is that a relational database model may not be the best solution for all situations. The easiest way to think of NoSQL, is that of a database which does not adhering to the traditional relational database management system (RDMS) structure. Sometimes you will also see it revered to as ‘not only SQL’.
  • It is not built on tables and does not employ SQL to manipulate data. It also may not provide full ACID (atomicity, consistency, isolation, durability) guarantees, but still has a distributed and fault tolerant architecture.
  • The NoSQL taxonomy supports key-value stores, document store, BigTable, and graph databases.


  • Why NoSQL? It’s high performance with high availability, and offers rich query language and easy scalability.
  • Relational and NoSQL data models are very different. The relational model takes data and separates it into many interrelated tables that contain rows and columns. Tables reference each other through foreign keys that are stored in columns as well.  When looking up data, the desired information needs to be collected from many tables (often hundreds in today’s enterprise applications) and combined before it can be provided to the application. Similarly, when writing data, the write needs to be coordinated and performed on many tables.

Mysql 5.5 to 5.6 version upgrade manualy

MySQL 5.6.12 version Upgrade

See the Steps follow given below:


 First of backup your whole wamp folder data and phpmyadmin database backup then after start this step.

This step follow time do not start your wamp server. If is running please stop all services.

1)      First of download latest wamp server link  and install PHP: 5.4.16, MySQL: 5.6.12, Apache: 2.4.4 your computer.

2)      Successfully install after find the wamp folder in your installed drive like [I.e. local disk (C :)].  Go to c:\wamp\bin\mysql\mysql5.6.12             path mysql5.6.12 folder copy and as you want to paste in another drive. [I.e. local disk (D :)]

3)      Then uninstall your latest wamp server from your computer and restart machine.

4)      Go to your installed drive wamp server and remove wamp folder from your drive. And second time install older version wamp server link and install PHP 5.3.13-Mysql 5.5.24-Apache 2.2.22 your computer

5)      Then complete installation after go to c:\wamp\bin\mysql\ path folder and new version mysql5.6.12 copy from your computer drive [ I.e. local disk (D :)] and paste new version mysql5.6.12

5-9-2013 11-51-48 AM

6)      Above process complete after go to older version c:\wamp\bin\mysql\mysql5.5.24\data folder copy and paste the new version go to c:\wamp\bin\mysql\mysql5.6.12\data.

7)      Then open the my.ini file and few changes need. Please see below screenshot. i.e. c:\wamp\bin\mysql\mysql5.6.12\my.ini

5-9-2013 12-28-59 PM

8)      Then go to c:\wamp\bin\mysql\mysql5.6.12\bin\mysql_upgrade.exe file and open the file mysql_upgrade.exe open the command prompt upgrade process complete after automatic close the prompt.

9)      All the step complete after please click on taskbar wamp icon-> mysql->version select mysql5.6.12 and restart your services.


10)   Another way to check mysql version click on taskbar wamp icon-> mysql->MySQL console and enter type select version();


Custom Display popular post in wordpress


Please add this function “wpb_track_post_views” in your main class file.


function wpb_set_post_views($postID) {
$count_key = ‘wpb_post_views_count’;
$count = get_post_meta($postID, $count_key, true);
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
else {
update_post_meta($postID, $count_key, $count);

function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;


//for popular post display
add_action( ‘wp_head’, array(&$this, ‘wpb_track_post_views’) );