Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: RocaPress Highlight Bloggers
  5. Description: The RocaPress Highlight Bloggers plugin gives you the oppurtunity to show all or certain bloggers on any page or post with a simple shortcode.
  6. Plugin URI: http://rocapress.com
  7. Author: RocaPress
  8. Author URI: http://rocapress.com
  9. Version: 1.0
  10. License: GPL2
  11. */
  12.  
  13. add_shortcode( 'bloggers', 'rocapress_highlight_bloggers' );
  14. function rocapress_highlight_bloggers( $atts, $content = null ) {
  15.  
  16. /* add shortcode parameters */
  17. $atts = shortcode_atts( array(
  18.         'role'      =>  'author',
  19.         'order'     =>  'ASC',
  20.         'orderby'   =>  'ID'
  21.     ), $atts, 'bloggers' );
  22.  
  23. $user_fields = array( 'ID' );
  24. $args = array(
  25. 'role'  =>  'author',
  26. 'order' =>  'ASC',
  27. 'orderby'   =>  'ID',
  28. 'fields' => $user_fields
  29. );
  30. $user_query = new WP_User_Query( $args );
  31. $authors = $user_query->get_results();
  32. $obj = new stdClass();
  33. $obj->ID = 1;
  34. array_push( $authors, $obj );
  35.  
  36.  
  37.  
  38.     // // Get the results
  39.     // $authors = $user_query->get_results();
  40.     // $total = $user_query->get_total();
  41.  
  42.     // Check for results
  43.     if ( ! empty( $authors ) ) {
  44.  
  45.         echo "Titus 2 er en blogg for kvinner som ønsker å vokse i troen. Vi er til sammen " . $total . " forfattere som ønsker å ære Gud i hverdagen gjennom å følge Hans ord. Vi skriver for å hjelpe andre lære det Gud har lært oss om hvordan å leve liv som gleder Han. Her kan du lese litt om hver av forfatterene:";
  46.         echo '<br><hr>';
  47.  
  48.         // loop trough each author
  49.         foreach ( $authors as $author ) {
  50.  
  51.             $gravatar = get_wp_user_avatar_src( $author->ID, 'avatar' );
  52.  
  53.             echo '
  54.  
  55.             <section class="author-box" itemprop="author" itemscope="itemscope" itemtype="http://schema.org/Person">
  56.                 <img src="' . $gravatar . '" width="70" height="70" alt="' . $author->first_name .' '. $author->last_name . '" class="avatar avatar-70 wp-user-avatar wp-user-avatar-70 photo avatar-default">
  57.                 <h4 class="author-box-title">Om <span itemprop="name">' . $author->first_name .' '. $author->last_name . '</span></h4>
  58.                 <div class="author-box-content" itemprop="description">
  59.                     <p>' . $author->description . '</p>
  60.                 </div>
  61.             </section>
  62.             <hr>';  
  63.         }
  64.  
  65.     } else {
  66.         echo 'No authors found';
  67.     }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement