Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to make edits to the following so that I can display the author and date but without those being links to searches 'by date' and 'by author'. The site I'm building will only have one author and I want to lock down the searches users can do.

Code as follows:

        <?php
            printf( __( '<span class="sep">Posted on </span><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s" pubdate>%3$s</time></a> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'toolbox' ),
                get_permalink(),
                get_the_date( 'c' ),
                get_the_date(),
                get_author_posts_url( get_the_author_meta( 'ID' ) ),
                sprintf( esc_attr__( 'View all posts by %s', 'toolbox' ), get_the_author() ),
                get_the_author()
            );
        ?>

Any help understanding what how this code block is working would be great. Thanks all.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The % signs are arguments in the string to be formatted. The s represents a string type argument must be passed. I've notated which arguments are connected to which strings being passed in.

get_permalink() - %1 string type
get_the_date( 'c' ) - %2 string type
get_the_date() - %3 string type
get_author_posts_url( get_the_author_meta( 'ID' ) ) %4 string type
sprintf( esc_attr(__( 'View all posts by %s', 'toolbox' ), get_the_author() ) %5 string type (Also %s refers to get_the_author())
get_the_author() - %6 string type

For more information see: http://php.net/manual/en/function.printf.php

share|improve this answer
add comment

Your Answer

 
discard

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.