OK, I found it on line 133 of template-tags.php. Can anyone help me rewrite the code to the PHP I need? When I paste in if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } it does not like it.
// translators: 1: who, 2: when
printf( __( '%1$s / %2$s', 'expound' ),
sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
If it helps, here is the entire function:
if ( ! function_exists( 'expound_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function expound_posted_on() {
$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
$regular_time = get_the_time( get_option( 'date_format' ) );
$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
$output_time = $regular_time;
// translators: 1: who, 2: when
printf( __( '%1$s / %2$s', 'expound' ),
sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
);
}
endif;
if ( ! function_exists( 'expound_human_time_diff' ) ) :
Here’s what is not working. You can tell I don’t know PHP:
printf( __( '%1$s / %2$s', 'expound' ),
sprintf( '<a class="author" rel="author" href="%s">%s</a>', if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
Be careful modifying a theme, if you update the theme then your changes will be lost. A child theme is a better idea.
That said, this should work:
function expound_posted_on() {
$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
$regular_time = get_the_time( get_option( 'date_format' ) );
$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
$output_time = $regular_time;
if ( function_exists( 'coauthors_posts_links' ) ) {
coauthors_posts_links();
} else {
// translators: 1: who, 2: when
printf( __( '%1$s / %2$s', 'expound' ),
sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
);
}
}
@johnnycardy, I am very grateful for your help. I made sure to build an Expound Child theme for template-tags.php and style.css.
However, the code still does not seem to be working: http://teenobserver.com/?p=1
Here is a GitHub Gist of EXACTLY what I have in template-tags: https://gist.github.com/laurenorsini/700a1a8cd85ac4ae0be7
The child theme might not be picking up the ‘/inc/template_tags.php’ file. I know it was generating an error earlier, but I’m assuming that’s before you decided to create a child theme.
Try deleting that file from your child theme, and instead, create a functions.php file in your child theme. The add the new expound_posted_on function into it. Don’t include the function_exists call. So all you should have is a style.css and a functions.php which looks like this:
<?php
function expound_posted_on() {
$human_time = expound_human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );
$regular_time = get_the_time( get_option( 'date_format' ) );
$output_time = sprintf( '%s <span style="display:none;">%s</span>', $human_time, $regular_time );
if ( current_time( 'timestamp' ) > get_the_time( 'U' ) + 60 * 60 * 24 * 14 )
$output_time = $regular_time;
if ( function_exists( 'coauthors_posts_links' ) ) {
coauthors_posts_links();
} else {
// translators: 1: who, 2: when
printf( __( '%1$s / %2$s', 'expound' ),
sprintf( '<a class="author" rel="author" href="%s">%s</a>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), get_the_author() ),
sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time )
);
}
}
?>
You were absolutely right. From now on, I’ll use functions.php if I need to add a new function to a child theme.
http://teenobserver.com/hello-world/
I really appreciate your help!