Permalink
Browse files

exclude step CPT entries from displaying in the widget

  • Loading branch information...
williamsba committed Apr 4, 2013
1 parent db36b96 commit 612f0c8c1b3f76c0d3efa4edc1742eda771cf2af
Showing with 23 additions and 18 deletions.
  1. +23 −18 includes/widgets/earned-user-achievements-widget.php
@@ -56,33 +56,38 @@ function widget( $args, $instance ) {
echo '<ul class="widget-achievements-listing">';
foreach ( $achievements as $achievement ) {
- $permalink = get_permalink( $achievement->ID );
- $title = get_the_title( $achievement->ID );
+ //exclude step CPT entries from displaying in the widget
+ if ( get_post_type( $achievement->ID ) != 'step' ) {
+
+ $permalink = get_permalink( $achievement->ID );
+ $title = get_the_title( $achievement->ID );
- $thumb = '';
- $image_attr = wp_get_attachment_image_src( get_post_thumbnail_id( $achievement->ID ), array( 50, 50 ) );
+ $thumb = '';
+ $image_attr = wp_get_attachment_image_src( get_post_thumbnail_id( $achievement->ID ), array( 50, 50 ) );
- if ( $image_attr ) {
+ if ( $image_attr ) {
- $img = '<img class="wp-post-image" width="'. absint( $image_attr[1] ) .'" height="'. absint( $image_attr[2] ) .'" src="'. esc_url( $image_attr[0] ) .'">';
- $thumb = '<a style="margin-top: -'. floor( absint( $image_attr[2] ) / 2 ) .'px;" class="badgeos-item-thumb" href="'. esc_url( $permalink ) .'">' . $img .'</a>';
- }
+ $img = '<img class="wp-post-image" width="'. absint( $image_attr[1] ) .'" height="'. absint( $image_attr[2] ) .'" src="'. esc_url( $image_attr[0] ) .'">';
+ $thumb = '<a style="margin-top: -'. floor( absint( $image_attr[2] ) / 2 ) .'px;" class="badgeos-item-thumb" href="'. esc_url( $permalink ) .'">' . $img .'</a>';
+ }
- $class = 'widget-badgeos-item-title';
- $item_class = $image_attr ? ' has-thumb' : '';
- $item_class .= credly_is_achievement_giveable( $achievement->ID ) ? ' share-credly' : '';
+ $class = 'widget-badgeos-item-title';
+ $item_class = $image_attr ? ' has-thumb' : '';
+ $item_class .= credly_is_achievement_giveable( $achievement->ID ) ? ' share-credly' : '';
- echo '<li id="widget-achievements-listing-item-'. absint( $achievement->ID ) .'" class="widget-achievements-listing-item'. esc_attr( $item_class ) .'">';
+ echo '<li id="widget-achievements-listing-item-'. absint( $achievement->ID ) .'" class="widget-achievements-listing-item'. esc_attr( $item_class ) .'">';
- echo $thumb;
- echo '<a class="widget-badgeos-item-title '. esc_attr( $class ) .'" href="'. esc_url( $permalink ) .'">'. esc_html( $title ) .'</a>';
- echo '</li>';
+ echo $thumb;
+ echo '<a class="widget-badgeos-item-title '. esc_attr( $class ) .'" href="'. esc_url( $permalink ) .'">'. esc_html( $title ) .'</a>';
+ echo '</li>';
- $thecount++;
+ $thecount++;
- if ( $thecount == $number_to_show && $number_to_show != 0 )
- break;
+ if ( $thecount == $number_to_show && $number_to_show != 0 )
+ break;
+
+ }
}
echo '</ul><!-- widget-achievements-listing -->';

0 comments on commit 612f0c8

Please sign in to comment.