- This topic has 4 replies, 3 voices, and was last updated 6 years, 4 months ago by Joni.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
December 16, 2017 at 11:19 am #450986Marcin
Help!
I added:
add_filter( 'generate_post_date_output','tu_add_to_post_date' ); function tu_add_to_post_date( $output ) { return '<i class="fa fa-clock-o" aria-hidden="true"></i> ' . $output; }
because I wanted the clock icon before the date.
It was ok, but i added also:
if ( ! function_exists( 'generate_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function generate_posted_on() { if ( 'post' !== get_post_type() ) return; $date = apply_filters( 'generate_post_date', true ); $author = apply_filters( 'generate_post_author', true ); $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) $time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%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() ) ); // If our date is enabled, show it if ( $date ) : printf( '<span class="posted-on">%1$s</span>', $time_string ); endif; // If our author is enabled, show it if ( $author ) : printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>', __( 'by','generate'), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'generate' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); endif; } endif;
becuase i wanted date without links. Unfortunetly, icon clock disappeared. What did I do wrong?
Example page: https://marcinszkodzinski.pl/kogo-tym-razem-nakrzyczy-kukiz/
December 16, 2017 at 8:13 pm #451182TomLead DeveloperLead DeveloperNo need for the second function.
You could do this instead:
add_filter( 'generate_post_date_output','tu_add_to_post_date' ); function tu_add_to_post_date( $output ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%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() ) ); return '<span class="posted-on"><i class="fa fa-clock-o" aria-hidden="true"></i> ' . $time_string . '</span'; }
December 17, 2017 at 2:25 am #451271MarcinAha! Thanks!
December 17, 2017 at 9:33 am #451486TomLead DeveloperLead DeveloperYou’re welcome 🙂
December 19, 2017 at 7:28 pm #453459JoniYou can also link to the FontAwesome CSS file in the wp-head hook, and use CSS to display the desired icon. Here is a tutorial I just created that might help.
https://pixelita.com/9649/using-breadcrumbs-with-generatepress/
-
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.