Add filters for posted on/by

```php
// Hide date last modified
add_filter( 'understrap_posted_on_time', 'prefix_hide_modified' );
function prefix_hide_modified() {
		$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
		$time_string = sprintf(
			$time_string,
			esc_attr( get_the_date( 'c' ) ),
			esc_html( get_the_date() )
		);
		return $time_string;
}

// Hide posted by
add_filter( 'understrap_posted_by', '__return_false' );

// Hide posted on
add_filter( 'understrap_posted_on', '__return_false' );
This commit is contained in:
IanDelMar 2018-09-18 23:02:54 +02:00 committed by GitHub
parent c810218613
commit eaacf2f606
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 8 deletions

View File

@ -26,15 +26,23 @@ if ( ! function_exists ( 'understrap_posted_on' ) ) {
esc_attr( get_the_modified_date( 'c' ) ), esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() ) esc_html( get_the_modified_date() )
); );
$posted_on = sprintf( $posted_on = apply_filters(
esc_html_x( 'Posted on %s', 'post date', 'understrap' ), 'understrap_posted_on', sprintf(
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' '<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
esc_html_x( 'Posted on', 'post date', 'understrap' ),
esc_url( get_permalink() ),
apply_filters( 'understrap_posted_on_time', $time_string )
)
); );
$byline = sprintf( $byline = apply_filters(
esc_html_x( 'by %s', 'post author', 'understrap' ), 'understrap_posted_by', sprintf(
'<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>' '<span class="byline"> %1$s<span class="author vcard"><a class="url fn n" href="%2$s">%3$s</a></span></span>',
esc_html_x( 'by', 'post author', 'understrap' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
)
); );
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. echo $posted_on . $byline; // WPCS: XSS OK.
} }
} }
@ -119,4 +127,4 @@ if ( ! function_exists ( 'understrap_category_transient_flusher' ) ) {
// Like, beat it. Dig? // Like, beat it. Dig?
delete_transient( 'understrap_categories' ); delete_transient( 'understrap_categories' );
} }
} }