CSS: .updated:not(.published)

Hey,
I just got a quick question: I use Advanced Custom Fields to create posts directly in the frontend.
In order to display the success message I need to reset this display: none:

.byline,
.updated:not(.published) {
	display: none;
}

Why did you set display to none here? And how can I display it? I already tried display:block !important;, that didn’t work.

Thank you very much!

We did it to hide the modified date as the post date meta should always display the publish date. This is commonly done by default WordPress theme like Twenty Seventeen.

To display it you can override the sydney_posted_on() function which is written in the inc/template-tags.php file template.

Paste this function into your child theme’s functions.php file or you can use the My Custom Functions plugin.


function sydney_posted_on() {
	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
	$post_date_label = __('Posted on', 'sydney');
	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
		$post_date_label = __('Modified on', 'sydney');
		$time_string = '<time class="entry-date published" datetime="%3$s">%4$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( '%1$s %2$s', 'post date', 'sydney' ),
		$post_date_label,
		'<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 ( ! is_single() && ! 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">' . __( 'Posted in %1$s', 'sydney' ) . '</span>', $categories_list );
	}
}

Regards,
Kharis

Thank you for your fast answer, Kharis!
Unfortunately, it doesn’t work. Maybe I have to clarify:

Advanced Custom Fields prints this success message right after the content title:

<h1>Write a post</h1>
<div id="message" class="updated"><p>Success!</p></div>

Unfortunately, the browser still doesn’t display it, since .updated:not is set to display: none in /themes/sydney/style.css.

.byline, .updated:not(.published) {
    display: none;
}

Don’t I just have to override this CSS setting? Thank you!

I am sorry for suggesting the incorrect solution.

Try adding the following CSS code into your site’s additional CSS option which resides under the Appearance > Customize > Additional CSS.


#message.updated {
  display: block !important;
}

Let me know how it goes.

Regards,
Kharis

Great, thank you, that works!

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis