0

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.

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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