access a cookie’s value immediately after calling the setcookie()

If you want to access a cookie’s value immediately after calling the setcookie() you can’t use $_COOKIE. The reason for this is in the nature of the protocol (see https://tools.ietf.org/html/rfc6265). When you use setcookie() it defines a Cookie to be sent along with the rest of the HTTP headers to the client (see http://php.net/manual/en/function.setcookie.php). But […]

Use of MYSQL Limit vs Offset

MySQL provides a LIMIT clause that is used to specify the number of records to return. The LIMIT clause makes it easy to code multi page results or pagination with SQL, and is very useful on large tables. Returning a large number of records can impact on performance. Assume we wish to select all records […]

Way to upgrade PHP5 to PHP7

Enter the following commands in the order shown: sudo apt-get -y update sudo add-apt-repository ppa:ondrej/php sudo apt-get -y update sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv Enter the following command to verify PHP 7.0.2 installed properly: php -v Following is a sample response that […]

Is WordPress best for E-commerce?

Top 10 Reason why people are choosing wordpress

Why WordPress is a best CMS ?

WordPress Interview Questions

How to add new tab to admin list of posts and handle result list

  add_action(‘views_edit-post’,’remove_edit_post_views’);function remove_edit_post_views( $views ){ $views[‘pre’]='<a href=”‘.admin_url().’edit.php?pre=pre”>My Special Posts</a>’;return $views;} add_action(‘pre_get_posts’,’my_special_list’);function my_special_list( $q ){ $scr = get_current_screen();if( is_admin()&&( $scr->base===’edit’)&& $q->is_main_query()){// To target only a post type uncomment following line and adjust post type name// if ( $scr->post_type !== ‘post’ ) return;// if you change the link in function above adjust next line accordingly $pre = […]

Validating Sanitizing and Escaping User Data

$title = sanitize_text_field( $_POST[‘title’] ); update_post_meta( $post->ID, ‘title’, $title ); Behinds the scenes, the function does the following: Checks for invalid UTF-8 (uses wp_check_invalid_utf8()) Converts single < characters to entity Strips all tags Remove line breaks, tabs and extra white space Strip octets The sanitize_*() class of helper functions are super nice for us, as […]

How to Display Any RSS Feed on Your WordPress Blog

<h2><?php _e( ‘Recent news from Some-Other Blog:’, ‘my-text-domain’ ); ?></h2> <?php // Get RSS Feed(s) include_once( ABSPATH . WPINC . ‘/feed.php’ ); // Get a SimplePie feed object from the specified feed source. $rss = fetch_feed( ‘http://www.wpbeginner.com/feed/’ ); if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly // […]