Change post meta on blog page and single posts

I love this theme but would like to change the way the post meta is displayed.
I’ve already hidden the author using css (not required) and am hoping these other changes might also be easy to implement:

On the blog page, it shows:
Posted on [date] [#] comments (clickable link) Posted in [categories]

My requests: 1. Remove the words “posted on” and "posted in"
2. Use this meta also on single posts (there is currently NO comments link showing there)

Thanks in advance!

My live site is in maintenence mode, but the staging site is still up: http://thedogladysden.wpstagecoach.com

Forgot: Please advise css to centre it. Thanks again!

Dear Debbie,

Try adding the following function into child theme’s functions.php file to override and modify the default post meta.


/**
 * Prints HTML with meta information for the current post-date/time and author.
 */
function sydney_posted_on() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$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() )
	);

	$posted_on = sprintf(
		_x( '%s', 'post date', 'sydney' ),
		'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
	);

	$byline = sprintf(
		_x( '%s', 'post author', 'sydney' ),
		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
	);

	echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';

	if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
		comments_popup_link( __( 'Leave a comment', 'sydney' ), __( '1 Comment', 'sydney' ), __( '% Comments', 'sydney' ) );
		echo '</span>';
	}

	$categories_list = get_the_category_list( __( ', ', 'sydney' ) );
	if ( $categories_list && sydney_categorized_blog() ) {
		printf( '<span class="cat-links">' . __( '%1$s', 'sydney' ) . '</span>', $categories_list );
	}
}

If you don’t want to use a child theme, alternatively you can use the Functionality plugin.

Regards,
Kharis

Thanks, Kharis! Please bear with me, as this is my first experience with a child theme. I copied your code into my child functions php file via Cyberduck and now it’s showing in the site header. What did I do wrong? The only code in the file before I added yours was this:

<?php
function my_theme_enqueue_styles() {

$parent_style = 'parent-style'; // This is 'sydney-pro-ii-style-' for the Sydney Pro theme.

wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style ),
    wp_get_theme()-&gt;get('Version')
);

}
add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
?>

Staging site: http://thedogladysden.wpstagecoach.com

I appreciate your patience.

Hello there,

Please remove the code you added. Then visit my previous reply where I shared the code. Then copy/paste after this line:


add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

Then remove ?> at the most bottom line.

Regards,
Kharis

Thank you; it worked! I really appreciate all your help. One final thing: Can it be centred using CSS? I haven’t been able to figure that out yet.

Your level of support for this theme is exceptional. Kudos!

Thanks & Regards,
Debbie

Dear Debbie,

Try adding this custom CSS code, please:


.hentry .meta-post{
  text-align: center;
}

Regards,
Kharis

Thanks a lot, Kharis! Have a good day.

You’re most welcome! Have a good day to you, too. :slight_smile:

Regards,
Kharis