Add vote system to custom content type in wordpress -


i have custom theme online shop (http://themeforest.net/item/mayashop-a-flexible-responsive-ecommerce-theme/2189918) comes multiple content types (besides default post type) , need add kind of vote system 1 of non-default content types ( product content type users can vote products of shop).

is there plugin provides funcionality?

thanks

there lot of plugins , can google them up, if want know how can (and primitivly) done of custom fields , here go :

add_action( 'wp_ajax_nopriv_o99__action', 'o99__ajax_cb' ); add_action( 'wp_ajax_o99__action', 'o99__ajax_cb' );  // fanction ajax callback. function o99__ajax_cb(){      // verify nonce make sure request ours , legael...      if( !isset( $_request['nonce'] ) || ! wp_verify_nonce( $_request['nonce'], 'o99__nonce' ) ) die( '-1' );      $post_id = isset( $_request['post_id'] ) ? absint( $_request['post_id'] ) : 0;      if( ! $post_id ) die( '-1' );      $counter = get_post_meta( $post_id, 'o99_good_post', true );     $counter = absint( $counter );     $cookie = 'o99_post_vote' .$post_id;      if( $counter){          if (!isset($_cookie[$cookie]) ) {             $counter++;         }         else {$counter=$counter;}      }     else{         $counter = mt_rand(20,150);     }      update_post_meta( $post_id, 'o99_good_post', $counter ); //hidden field     echo $counter;      die(); }   function o99__good_bad(){     global $post;     // send simple cookie     $cookie = 'o99_post_vote' .$post_id;     $count = get_post_meta( $post->id, 'o99_good_post', true ); //hidden field      if (!$count ){         $count = '0';     }      $icon = '<img src="';     $icon .= get_bloginfo('template_url') ; // better using get_stylesheet_uri()      if (!isset($_cookie[$cookie]) ) {         $icon .= '/images/dl-star16.png"/>'; // set icons according case     }     else {         $icon .= '/images/dl-v16.png"/>';     }       ?>     <span id="o99__click" title="click here vote post up"><?php echo $icon; ?> click here vote     post voted <span id="o99__count"><?php echo strip_tags( $count );?>     </span> times</span>     <?php }  // injecting js head -- add_action( 'wp_head', 'o99__head' );  function o99__head() {     if( ! is_singular() ) return;     $post_id = get_queried_object_id();     ?>     <script type="text/javascript">         var o99__data = {             action: 'o99__action',             post_id: '<?php echo absint( $post_id ); ?>',             nonce: '<?php echo wp_create_nonce( 'o99__nonce' ); ?>',         }          jquery(document).ready(function(){             jquery( '#o99__click' ).click(function(){                  jquery.get(                      '<?php echo site_url( 'wp-admin/admin-ajax.php' ); ?>',                      o99__data,                      function( data ){                     if(jquery.cookie('o99_post_vote<?php echo absint( $post_id ); ?>') != null) {                              alert( 'you can vote once per post!' );                                     };                     if(jquery.cookie('o99_post_vote<?php echo absint( $post_id ); ?>') == null) {                            if( '-1' != data )                         {                             jquery( 'span#o99__count' ).html( data );                             jquery.cookie('o99_post_vote<?php echo absint( $post_id ); ?>', 'voted', { expires: 7 });                              alert( 'your vote accepted!' );                              };                         }                     }                 );             });         });     </script>     <?php } ?> 

this old function hacked long time ago, should still work, maybe need bit of polish ..

edit i examples of more complex plugins :

http://wordpress.org/extend/plugins/post-ratings/ http://wordpress.org/extend/plugins/post-ratings/screenshots/ http://wordpress.org/extend/plugins/gd-star-rating/ , if search codex find more ..

those listed above support custom post types .


Comments