Title: printf and comments_number() order
Last modified: August 19, 2016

---

# printf and comments_number() order

 *  [bzmillerboy](https://wordpress.org/support/users/bzmillerboy/)
 * (@bzmillerboy)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/printf-and-comments_number-order/)
 * I’m customizing the starkers theme which re-uses a lot of the **twentyten functions**.
   I’d like to display the post meta data using this modified **twentyten_posted_on()**
   function.
 *     ```
       function twentyten_posted_on() {
       	printf( __( '%2$s <span class="meta-sep">by</span> %3$s', 'twentyten' ),
       			'meta-prep meta-prep-author',
       			sprintf( '<span class="entry-date">%3$s</span>',
       				get_permalink(),
       				esc_attr( get_the_time() ),
       				get_the_date()
       			),
       			sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
       				( get_the_author_meta( 'ID' ) ),
       				sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
       				get_the_author()
       			),
       			sprintf( '<span>%1$s</span>',
       				comments_number('No Comments', '1 Comment', '% Comments')
       			)
       	);
       }
       endif;
       ```
   
 * For some reason it’s outputs **“No CommentsOctober 6, 2010 by bzmillerboy” instead
   of “October 6, 2010 by bzmillerboy No Comments”**.
 * I finally had to pull the comments_numbers out of the functions.php and put it
   after the function on the single.php, like this.
 * `<?php twentyten_posted_on(); ?> <?php comments_number('No Comments', '1 Comment','%
   Comments') ?>`
 * Any suggestions on how to get this to work within the function?

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

 *  Thread Starter [bzmillerboy](https://wordpress.org/support/users/bzmillerboy/)
 * (@bzmillerboy)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/printf-and-comments_number-order/#post-1827579)
 * It at least is outputing everything, but I can’t figure out why it’s not in the
   right order.
 * I have a feeling it is similar to this issue, but still don’t understand.
 * [http://wordpress.org/support/topic/printf-weirdness-with-comment_author_link](http://wordpress.org/support/topic/printf-weirdness-with-comment_author_link)
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/printf-and-comments_number-order/#post-1827665)
 * yes, it is related:
 * [http://codex.wordpress.org/Function_Reference/comments_number](http://codex.wordpress.org/Function_Reference/comments_number)
 * `comments_number()` outputs the result; in your context you need to use `get_comments_number()`
   
   [http://codex.wordpress.org/Template_Tags/get_comments_number](http://codex.wordpress.org/Template_Tags/get_comments_number)
   with the added complications
 * and you also need to use this as the fourth variable for you printf:
 * something like:
    `printf( __( '%2$s <span class="meta-sep">by</span> %3$s, %4
   $s', 'twentyten' ),`

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

The topic ‘printf and comments_number() order’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [printf](https://wordpress.org/support/topic-tag/printf/)
 * [sprintf](https://wordpress.org/support/topic-tag/sprintf/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/printf-and-comments_number-order/#post-1827665)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
