Title: Code into Template-Tags.php File
Last modified: August 30, 2016

---

# Code into Template-Tags.php File

 *  Resolved [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/)
 * Hey there,
 * I’m trying to add the code <?php wp_days_ago_v3 ($showDateAfter) ?> into the 
   php where the date coding resides. However, I’m having trouble doing this. This
   is the code and you can see below where I’m trying to insert the plugin code.
   Any help would be greatly appreciated. Thanks!
 *  printf( __( ‘<span class=”byline”><i class=”fa fa-user”></i>%1$s</span><span
   class=”posted-on”><i class=”fa fa-calendar”><?php wp_days_ago_v3 ($showDateAfter)?
   ></i>%2$s</span>’, ‘themememe’ ),
    sprintf( ‘<span class=”author vcard”>[%2$s](https://wordpress.org/support/topic/code-into-template-tagsphp-file/%1$s?output_format=md)
   </span>’, esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ), esc_html(
   get_the_author() ) ), sprintf( ‘<!–[–>%2$s<!–](https://wordpress.org/support/topic/code-into-template-tagsphp-file/%1$s?output_format=md)–
   >’, esc_url( get_permalink() ), $time_string
 *  )
    );
 * [https://wordpress.org/plugins/wp-days-ago/](https://wordpress.org/plugins/wp-days-ago/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Vegard Skjefstad](https://wordpress.org/support/users/vskjefst/)
 * (@vskjefst)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239422)
 * Sorry for the late reply. Give this a try. It’s untested and I’m assuming you’ve
   defined both $stopUsingAjaxAfter and $showDateAfter somewhere else in your code.
   If not, replace $stopUsingAjaxAfter with 0 and $showDateAfter with when you want
   the plugin to start showing the actual date something was published (in seconds
   after it was published). Using a value of 3600, for instance, will make the plugin
   start showing the date instead of “X minutes ago” after one hour.
 * Please have a look at the documentation for further information about the available
   options the plugin supports: [https://wordpress.org/plugins/wp-days-ago/installation/](https://wordpress.org/plugins/wp-days-ago/installation/)
 *     ```
       printf( __( '<span class="byline"><i class="fa fa-user"></i>%1$s</span><span class="posted-on"><i class="fa fa-calendar">%2$s</i>%3$s</span>', 'themememe' ),
       sprintf( '<span class="author vcard">%2$s</span>',
       esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
       esc_html( get_the_author() )
       ),
       wp_days_ago_v3($stopUsingAjaxAfter, $showDateAfter)
       ,
       sprintf( '<!---->%2$s<!---->',
       esc_url( get_permalink() ),
       $time_string)
       );
       ```
   
 *  Thread Starter [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239429)
 * Hey Vegard,
 * Thanks for help. Humorously, your notes helped me find where the code should 
   be placed, however, I don’t know how to adjust properly to display. Currently,
   I have:
 * sprintf( ‘wp_days_ago_v3(172800);’,
 * But how do I make it work inside of the single quotes ‘ ‘
 * Thanks,
    Corey
 *  Plugin Author [Vegard Skjefstad](https://wordpress.org/support/users/vskjefst/)
 * (@vskjefst)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239430)
 * The point of the sprintf function is that it returns a formatted string. This
   might work:
 * `sprintf('%s', wp_days_ago_v3(172800));`
 * sprintf should replace the %s with the output of the wp_days_ago_v3 function.
 * Another example is
 * `sprintf('Published %s', wp_days_ago_v3(172800));`
 * which should output something like “Published 3 minutes ago”.
 * You should also have a look at the PHP sprintf documentation: [http://php.net/manual/en/function.sprintf.php](http://php.net/manual/en/function.sprintf.php)
 *  Thread Starter [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239431)
 * I understand now. I guess the issue that I’m having is that the function keeps
   showing up before the other information (author, category).
 * Here’s the code & you can look at condensus.com to see that the “days ago” function
   shows at the beginning…
 * function themememe_posted_on() {
    $time_string = ‘<time class=”entry-date published”
   datetime=”%1$s”>%2$s</time>’;
 *  $time_string = sprintf( $time_string,
    esc_attr( get_the_date( ‘c’ ) ), esc_html(
   get_the_date() ), esc_attr( get_the_modified_date( ‘c’ ) ), esc_html( get_the_modified_date()));
 *  printf( __(‘ <span class=”byline”><i class=”fa fa-user”></i>%1$s</span><span
   class=”posted-on”><i class=”fa fa-calendar”></i>wp_days_ago_v3(84600)</span>’,‘
   themememe’ ),
    sprintf( ‘<span class=”author vcard”>[%2$s](https://wordpress.org/support/topic/code-into-template-tagsphp-file/%1$s?output_format=md)
   </span>’, esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ), esc_html(
   get_the_author() ) ), sprintf(‘%s’, wp_days_ago_v3(172800), esc_url( get_permalink()),
   $time_string ) ); } endif;
 *  Plugin Author [Vegard Skjefstad](https://wordpress.org/support/users/vskjefst/)
 * (@vskjefst)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239435)
 * First of all, you should remove the “wp_days_ago_v3(84600)” inside
 * `<i class="fa fa-calendar"></i>wp_days_ago_v3(84600)</span>`
 * Where, exactly, in the line below the headline, do you want the “days ago” information
   to be displayed?
 *  Thread Starter [cjohnson26](https://wordpress.org/support/users/cjohnson26/)
 * (@cjohnson26)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239436)
 * I would like the “days ago” information to be displayed to the right of the calendar.
   Where I currently have the “wp_days_ago_v3(84600)” displayed.
 * For some reason, the actual “days ago” information keeps showing up at the beginning
   of the themememe_posted_on() function.
 *  Plugin Author [Vegard Skjefstad](https://wordpress.org/support/users/vskjefst/)
 * (@vskjefst)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239437)
 * I see. Try to replace the themememe_posted_on function with the following (untested)
   version:
 *     ```
       function themememe_posted_on() {
       	printf('<span class="posted-on"><i class="fa fa-calendar"></i>%s</span>', wp_days_ago_v3(172800));
       }
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Code into Template-Tags.php File’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-days-ago.svg)
 * [wp-days-ago](https://wordpress.org/plugins/wp-days-ago/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-days-ago/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-days-ago/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-days-ago/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-days-ago/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-days-ago/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Vegard Skjefstad](https://wordpress.org/support/users/vskjefst/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/code-into-template-tagsphp-file/#post-6239437)
 * Status: resolved