wordpress - How to insert this php instruction into printf result? -
i new in php world , customizing wordpress template.
i have following function in php file:
function admired_posted_on() { printf( __( '<span class="sep">posted on </span> <a href="%1$s" title="%2$s" rel="bookmark"> <time class="entry-date" datetime="%3$s" pubdate>%4$s</time> </a> <span>blabla</span> <span class="by-author"> <span class="sep"> bla</span> <span class="author vcard"> <a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a> </span> </span> ', 'admired' ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_url( get_author_posts_url( get_the_author_meta( 'id' ) ) ), sprintf( esc_attr__( 'view posts %s', 'admired' ), get_the_author() ), esc_html( get_the_author() ) ); }
now, have insert inside printf body following php code blabla tag instead of "blabla" text. php code have insert:
<?php echo '(' . get_postviews(get_the_id()) . ')'; ?>
if insert ithis row previous span tag go error.
the get_postviews(get_the_id()) return integer have show in span
someone can me?
if there single quotes '
in string enclosed single quotes have escape quotes. (note \'
):
$string = '<span class="sep">posted on <?php echo \'(\' . get_postviews(get_the_id()) . \')\'; ?></span>... more content ....';
but in example following solution might simpler:
$string = '<span class="sep">posted on (<?php echo get_postviews(get_the_id()); ?>)</span>... more content ....';
Comments
Post a Comment