social share buttons

<div class="social-share-btn">

        <div id="fb-root"></div>

<script>(function(d, s, id) {

 var js, fjs = d.getElementsByTagName(s)[0];

 if (d.getElementById(id)) return;

 js = d.createElement(s); = id;

 js.src = "//";

 fjs.parentNode.insertBefore(js, fjs);

}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-share-button" data-href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>" data-layout="button_count"></div>

<a href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>" data-count="horizontal" class="twitter-share-button">Tweet</a>

<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

<!-- Place this tag in your head or just before your close body tag. -->

<script src="" async defer></script>

<!-- Place this tag where you want the share button to render. -->

<div class="g-plus" data-action="share" data-annotation="bubble" data-href="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>"></div>

<script src="//" type="text/javascript">

 lang: en_US


<script type="IN/Share" data-counter="right" data-url="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>"></script>


create virtual host in Ubantu

create virtual host

Localhost name will be : api.local.btv

file's path : /var/www/html/projectfolder/api/web

Step 1 :

create conf file with below command

sudo nano /etc/apache2/sites-available/api.local.btv.conf

Step 2 : paste below code and save and exit

<VirtualHost *:80>

    # The ServerName directive sets the request scheme, hostname and port that

    # the server uses to identify itself. This is used when creating

    # redirection URLs. In the context of virtual hosts, the ServerName

    # specifies what hostname must appear in the request's Host: header to

    # match this virtual host. For the default virtual host (this file) this

    # value is not decisive as it is used as a last resort host regardless.

    # However, you must set it for any further virtual host explicitly.


    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/html/projectfolder/api/web


        ServerName  api.local.btv

        ServerAlias api.local.btv

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

    # error, crit, alert, emerg.

    # It is also possible to configure the loglevel for particular

    # modules, e.g.

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are

    # enabled or disabled at a global level, it is possible to

    # include a line for only one particular virtual host. For example the

    # following line enables the CGI configuration for this host only

    # after it has been globally disabled with "a2disconf".

    #Include conf-available/serve-cgi-bin.conf


Step 3 : sudo a2ensite api.local.btv.conf

Step 4 : sudo service apache2 restart.

Step 5: Enter one entry into /etc/hosts file as below       api.local.btv

And it’s done. TADA.
Now you can access your website in the browser by hitting this URL http://api.local.btv

Facebook , Twitter and Pinterest share button code

<div style="width:300px; border:solid 1px;">
				<div id="fb-root"></div>
				<script>(function(d, s, id) {
				  var js, fjs = d.getElementsByTagName(s)[0];
				  if (d.getElementById(id)) return;
				  js = d.createElement(s); = id;
				  js.src = "//";
				  fjs.parentNode.insertBefore(js, fjs);
				}(document, 'script', 'facebook-jssdk'));</script>
				<div class="fb-share-button" data-href="<?php the_permalink();?>" data-layout="button_count"></div> 


<a href="" class="twitter-share-button" >Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>


<a href="{URI-encoded URL of the page to pin}&media={URI-encoded URL of the image to pin}&description={optional URI-encoded description}" class="pin-it-button" count-layout="horizontal">
    <img border="0" src="//" title="Pin It" />

Register custom post type

add_action( 'init', 'codex_book_init' );


 * Register a book post type.


 * @link


function codex_book_init() {

    $labels = array(

        'name' => _x( 'Books', 'post type general name', 'your-plugin-textdomain' ),

        'singular_name' => _x( 'Book', 'post type singular name', 'your-plugin-textdomain' ),

        'menu_name' => _x( 'Books', 'admin menu', 'your-plugin-textdomain' ),

        'name_admin_bar' => _x( 'Book', 'add new on admin bar', 'your-plugin-textdomain' ),

        'add_new' => _x( 'Add New', 'book', 'your-plugin-textdomain' ),

        'add_new_item' => __( 'Add New Book', 'your-plugin-textdomain' ),

        'new_item' => __( 'New Book', 'your-plugin-textdomain' ),

        'edit_item' => __( 'Edit Book', 'your-plugin-textdomain' ),

        'view_item' => __( 'View Book', 'your-plugin-textdomain' ),

        'all_items' => __( 'All Books', 'your-plugin-textdomain' ),

        'search_items' => __( 'Search Books', 'your-plugin-textdomain' ),

        'parent_item_colon' => __( 'Parent Books:', 'your-plugin-textdomain' ),

        'not_found' => __( 'No books found.', 'your-plugin-textdomain' ),

        'not_found_in_trash' => __( 'No books found in Trash.', 'your-plugin-textdomain' )


    $args = array(

        'labels' => $labels,

                'description' => __( 'Description.', 'your-plugin-textdomain' ),

        'public' => true,

        'publicly_queryable' => true,

        'show_ui' => true,

        'show_in_menu' => true,

        'query_var' => true,

        'rewrite' => array( 'slug' => 'book' ),

        'capability_type' => 'post',

        'has_archive' => true,

        'hierarchical' => false,

        'menu_position' => null,

        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )


    register_post_type( 'book', $args );


Remove Description tab if empty in woocommerce – codeforall

Below for line code can do magic if you want to remove the description tab from woocommerce single product page

just add this code to your tabs.php


        $product_detail = get_post(get_the_ID())->post_content;



            $description = 0;




copy and paste the above code in tabs.php file just above where it starts

How to add Custom column for custom post type on backend

add_filter( 'manage_edit-cptx_business_columns', array($this, 'customColumns') ) ;

add_action( 'manage_cptx_business_posts_custom_column', array($this, 'myCustomColumns'), 10, 3 );

public function myCustomColumns($column, $post_id) {

        global $post;

        $user_ID = get_current_user_id();

        $count_user_posts_by_type= create_function('$userid,$meta_key, $meta_value, $post_type','

            global $wpdb;

            $where = " WHERE post_type = \'cptx_rental\' AND post_author = 4 AND postmeta.meta_value=\'$meta_value\' AND postmeta.meta_key = \'$meta_key\' ";

            $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts posts left join $wpdb->postmeta postmeta on(postmeta.post_id $where " );

            return apply_filters( \'get_usernumposts\', $count, $userid );


        $total_rentals = $count_user_posts_by_type($user_ID,"_cptx_rental_client_id",$post->ID,'cptx_rental');

        $total_business = $count_user_posts_by_type($user_ID,"_cptx_rental_client_id",$post->ID,'cptx_business');

        switch( $column ) {

            case 'business_type' :

                $terms = wp_get_post_terms( $post_id, 'cptx_business_listing_type' );

                echo $terms[0]->name;


            case 'num_businesses' :

                echo $total_business;


            case 'users':

                $client_id = get_post_meta($post_id, '_cptx_rental_client_id', true);

                $client_meta = get_post_meta( $client_id ,'_cl_first_name',true);

                echo $client_meta;


            /* Just break out of the switch statement for everything else. */

            default :




public function customColumns() {

        $columns = array(

            'cb' => '<input type="checkbox" />',

            'title' => __( 'Title' ),

            'business_type' => __( 'Business Type' ),           

            'thumb' => __( 'Thumb' ),

            'users' => __( 'Users' ),

            'date' => __( 'Date' ),


        return $columns;


Leverage Browser Caching with WordPress

Add the below code into your .htaccess file and then check your page speed


<IfModule mod_expires.c>

ExpiresActive On

ExpiresByType image/jpg "access 1 year"

ExpiresByType image/jpeg "access 1 year"

ExpiresByType image/gif "access 1 year"

ExpiresByType image/png "access 1 year"

ExpiresByType text/css "access 1 month"

ExpiresByType text/html "access 1 month"

ExpiresByType application/pdf "access 1 month"

ExpiresByType text/x-javascript "access 1 month"

ExpiresByType application/x-shockwave-flash "access 1 month"

ExpiresByType image/x-icon "access 1 year"

ExpiresDefault "access 1 month"