Posts

Showing posts from April, 2016

Easy steps (Snippet) for create custom post type or multiple post types

Just copy and paste below code into functions.php or into your custom plugins file and change according to your need.. Here i create two different post types "Story" and "Chapters" . add_action( 'init', 'rj_custom_post_types' ); function rj_custom_post_types() {     $cps = array();     $cps['story'] = 'Story'; // add your custom post type here slug as key and name as value.     $cps['chapter'] = 'Chapter';     $icons = array('dashicons-media-interactive','dashicons-book');  // if you want to add icons then place icon slug here     if(!empty($cps) && count($cps)>0)     {         $i = 0;         foreach($cps as $key => $value)         {             $labels = array();             $args = array();             $labels = array(         'name'               => _x( $value, 'post type general name', 'qode' ),         'singular_name'      =>

Wordpress count visitor for single post

Just copy and paste below code into functions.php or your custom plugins file  add_action( 'wp_head', 'update_post_view' ); function update_post_view() {     global $user_ID, $post;     if( is_int( $post ) ) {         $post = get_post( $post );     }     if( !wp_is_post_revision( $post ) ) {         if( is_single() || is_page() ) {             $id = intval( $post->ID );                         if ( !$post_views = get_post_meta( $post->ID, '_visitor_count', true ) ) {                 $post_views = 0;             }             $should_count = true;               $bots = array                 (                       'Google Bot' => 'googlebot'                     , 'Google Bot' => 'google'                     , 'MSN' => 'msnbot'                     , 'Alex' => 'ia_archiver'                     , 'Lycos' => 'lycos'                     , 'Ask Jeeves' => &

How to save post visit or count post visit in wordpress

For get post visit or count post visit just copy and paste below code into your theme's functions.php file add_action( 'wp_head', 'update_post_view' ); function update_post_view() {     global $user_ID, $post;     if( is_int( $post ) ) {         $post = get_post( $post );     }     if( !wp_is_post_revision( $post ) ) {         if( is_single() || is_page() ) {             $id = intval( $post->ID );                         if ( !$post_views = get_post_meta( $post->ID, '_visitor_count', true ) ) {                 $post_views = 0;             }             $should_count = true;               $bots = array                 (                       'Google Bot' => 'googlebot'                     , 'Google Bot' => 'google'                     , 'MSN' => 'msnbot'                     , 'Alex' => 'ia_archiver'                     , 'Lycos' => 'lycos'