Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using wordpress with woocommerce and I am trying to manipulate a copy of myaccount.php The default code uses some variables of some sort that I am not familiar with nor have I been able to find documentation on. The variables in question are %1$s, %2$s and %s

<p class="myaccount_user">
    __( 'Hello <strong>%1$s</strong> (not %1$s? <a href="%2$s">Sign out</a>).', 'woocommerce' ) . ' ',
    wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) )

printf( __( 'From this page you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),

How can I identify the variables, what they represent and how to use them?

Thank you.

share|improve this question
up vote 1 down vote accepted

The %1$s and %2$s are standard "conversion specifications" (ie. placeholders) used with the printf() family of PHP functions (nothing to do with WordPress or WooCommerce). They are replaced with the argument values that are passed to the printf() function.

So, in the first example, %1$s is replaced with the value of $current_user->display_name (1st argument) and %2$s is replaced with the value returned from wp_logout_url( get_permalink( wc_get_page_id( 'myaccount' ) ) ) (2nd argument).

The placeholder specifies how the value is displayed.

  • % indicates the start of the placeholder.

  • The number 1 that follows is a reference to which argument, either 1 or 2 in this example.

  • s indicates a string.

Further reference:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.