Title: Add Points Shortcode to PHP
Last modified: August 22, 2016

---

# Add Points Shortcode to PHP

 *  Resolved [robint](https://wordpress.org/support/users/robint/)
 * (@robint)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/)
 * I’m trying to add the “user points” hook to an individual profile page.
 * E.g
 * Tim has ” % no of points” — Tim’s Profile Page
 * Jack has ” % no of points” — Jack’s Profile Page
 * How do I add this shortcode to author.php ?
 * Robin
 * [https://wordpress.org/plugins/wordpoints/](https://wordpress.org/plugins/wordpoints/)

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

 *  Plugin Author [J.D. Grimes](https://wordpress.org/support/users/jdgrimes/)
 * (@jdgrimes)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771180)
 * You can use the [`wordpoints_display_points()`](https://github.com/WordPoints/wordpoints/blob/fef99b6e37161884940acfbfd65453d0d8ad5c96/src/components/points/includes/points.php#L425-L450)
   function. You just need to provide it the user’s ID, the slug of the points type,
   and a “context” string.
 * It would look something like this:
 *     ```
       echo esc_html( $author->user_firstname ) . ' has ';
       wordpoints_display_points( $author->ID, 'points', 'author-profile' );
       ```
   
 *  Thread Starter [robint](https://wordpress.org/support/users/robint/)
 * (@robint)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771208)
 * I’m trying to add it to the menu bar;
 *     ```
       <?php
                                   $points = $wordpoints_display_points();
                                   ?>
   
       <li><a href="http://website.com/top-user-points/"> Points (<?php echo $wordpoints_display_points( $author->ID; ?>)</a></li>
       ```
   
 * What have I done wrong?
 *  Thread Starter [robint](https://wordpress.org/support/users/robint/)
 * (@robint)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771209)
 *  Plugin Author [J.D. Grimes](https://wordpress.org/support/users/jdgrimes/)
 * (@jdgrimes)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771212)
 * Try this:
 *     ```
       <li><a href="http://website.com/top-user-points/"> Points (<?php wordpoints_display_points( $author->ID, 'points', '' ); ?>)</a></li>
       ```
   
 * If that doesn’t work, you can send me a copy of the template, or post a link 
   to the code, and I’ll try to find the problem.
 *  Thread Starter [robint](https://wordpress.org/support/users/robint/)
 * (@robint)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771227)
 * Nearly there,
    It’s displaying apart from the number. I’m adding it to the header.
   php
 * Therefore it requires a hook call.
    Similar to;
 *     ```
       <?php
        $fep = new fep_main_class();
       $numNew = $fep->getNewMsgs();
       ?>
       ```
   
 * Placed just above;
 *     ```
       <li><a href="http://xxxx.com/top-user-points/"> Points(<?php wordpoints_display_points( $user_info->ID, 'points', '' ); ?>)</a></li>
       ```
   
 *  Thread Starter [robint](https://wordpress.org/support/users/robint/)
 * (@robint)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771232)
 * Got it to work with ;
 * `<li><a href="http://guysandgirls.directory/top-user-points/"> Points(<?php echo
   do_shortcode( '[wordpoints_points points_type="points"]' );?>)</a></li>`

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

The topic ‘Add Points Shortcode to PHP’ is closed to new replies.

 * ![](https://ps.w.org/wordpoints/assets/icon.svg?rev=1662380)
 * [WordPoints](https://wordpress.org/plugins/wordpoints/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpoints/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpoints/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpoints/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpoints/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpoints/reviews/)

## Tags

 * [Profile Page](https://wordpress.org/support/topic-tag/profile-page/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 6 replies
 * 2 participants
 * Last reply from: [robint](https://wordpress.org/support/users/robint/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/add-points-shortcode-to-php/#post-5771232)
 * Status: resolved