Rearrange PHP Code

I have this snippet of code below:


<h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

that returns something like this; “Category Archives: Recent News”.

I am wanting to rearrange the output to read something like this; “Recent News Category Archives”.
Can someone show me how to do this?

Shouldn’t it be something as simple as this?


<h1 class="page-title"><?php printf( __( '%s Category Archives', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>

Thanks DaveMaxwell. That worked. I am a PHP noob so it may have been simple for you but I had no idea what I was doing. Thanks again!

No worries. To explain for future use - the %s is what is replaced in the statement, so I just moved it from one place in the statement to the other so you got the format you wanted.

So the percent symbol is the variable that represents the name of the category, correct?

Kind of, the %s is a placeholder for a variable; in this case ‘<span>’ . single_cat_title( ‘’, false ) . ‘</span>’ gets placed where the %s is located.

With printf, you can set placeholders that are replaced when outputted in the order that you list them. Example:

printf('My test with two placeholders %s and %s', 'this shows up after placeholders', 'this shows up after and');

There are a lot more placeholders than just %s that can be used with printf, but you won’t run into those often in WordPress.