Title: shortcode with post_id solved
Last modified: August 24, 2016

---

# shortcode with post_id solved

 *  Resolved [luciver](https://wordpress.org/support/users/luciver/)
 * (@luciver)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/)
 * @yasr-shortcode-functions.php
 * add_shortcode (‘yasr_visitor_votes_readonly’, ‘yasr_visitor_votes_readonly_callback’);
   
   function yasr_visitor_votes_readonly_callback ($atts) { $shortcode_html = NULL;**
   $a = shortcode_atts( array( ‘id’ => get_the_ID(), ), $atts ); $post_id = $a[‘
   id’]; //$post_id = get_the_ID(); $votes=yasr_get_visitor_votes($post_id);
 * [https://wordpress.org/plugins/yet-another-stars-rating/](https://wordpress.org/plugins/yet-another-stars-rating/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [luciver](https://wordpress.org/support/users/luciver/)
 * (@luciver)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051505)
 * Oups maybe a pro feature, If it, I delete.
 *  Plugin Contributor [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051737)
 * Hi luciver, thank you for using YASR!
 * not sure what are you trying to do here?
    Seems like you want to pass the post
   id as a shortcode argument, but it will simply get overwritten by the get_the_ID().
 * Further, there is no need at all to pass post id as argument cause the function
   get the post id itself (with the line you comment out)
 * Have I missed anything?
 * Best,
    Dario
 *  Thread Starter [luciver](https://wordpress.org/support/users/luciver/)
 * (@luciver)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051741)
 * On page that have a list of post, the id must be pass to work, otherwise, we 
   have the rank of the page but not for each post. Just needed on sensei than not
   allow ranking without a product…
    So I had changed to pass the id.
 * Other thing, you havent implement **Enabling Rich Snippets** or it s a pro feature?
   
   I m looking for it in [yasr_visitor_votes_readonly]
 * Tks
 *  Plugin Contributor [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051745)
 * Ok, but why change the shortcode atts? You can pass the post_id to yasr_get_visitor_votes
   simply using
 *     ```
       $post_id = get_the_ID();
       $votes=yasr_get_visitor_votes($post_id);
       ```
   
 * $a[‘id’] and $post_id are just the same thing
 * Rich snippets are avaible in free version too. They will appear if you use the
   overall rating or the yasr_visitor_votes shortcode: you can see it on your post/
   page where you use that shortcode.
 * Using that in the readonly one is a non sense, because that function have to 
   print the stars and stars only, to integrate it in a template.
 * The rich snippet instad add a text, read here [https://wordpress.org/support/topic/remove-sentence-at-the-end-of-post?replies=11](https://wordpress.org/support/topic/remove-sentence-at-the-end-of-post?replies=11)
 *  Thread Starter [luciver](https://wordpress.org/support/users/luciver/)
 * (@luciver)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051773)
 * Tks I see it 🙂
 * For the parameter, it s the same, but in the loop-course, it seems that the $
   post_id is not set. It comes from an other part
    _$posts\_array = $woothemes\
   _sensei->post\_types->course->course\_query( $amount, $query\_type, $course\_includes,
   $course\_excludes ); <?php foreach ($posts\_array as $post\_item){ array\_push(
   $course\_excludes, $post\_item->ID ); $post\_id = absint( $post\_item->ID );
 * If I remove the parameter, it does not work.
 * Ok all good, just add a way to reset vote.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘shortcode with post_id solved’ is closed to new replies.

 * ![](https://ps.w.org/yet-another-stars-rating/assets/icon-256x256.png?rev=1525329)
 * [YASR - Yet Another Star Rating Plugin for WordPress](https://wordpress.org/plugins/yet-another-stars-rating/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yet-another-stars-rating/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yet-another-stars-rating/)
 * [Active Topics](https://wordpress.org/support/plugin/yet-another-stars-rating/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yet-another-stars-rating/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yet-another-stars-rating/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [luciver](https://wordpress.org/support/users/luciver/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/shortcode-with-post_id-solved/#post-6051773)
 * Status: resolved