WordPress.org

Ready to get started?Download WordPress

Forums

Ryu
[resolved] Patch: show published and modified dates on pages (3 posts)

  1. Ryan
    Member
    Posted 10 months ago #

    Hi Caroline, Lance, and other Ryu theme wrangler(s)! I've done a lot of CSS hacking on my Ryu installation, but I finally hit something I needed to change the theme code for: published and modified dates on pages.

    Here's the patch against Ryu 1.1. I'd love to see it incorporated into the next version!

    Here's an example: http://snarfed.org/about

    The dates are included in entry-meta, like in posts, with appropriate CSS classes so users can easily style them. I can also make them opt in using config variables or theme customization if you want.

    diff -ru ryu/content-page.php /Users/ryan/wc/themes/ryu/content-page.php
    --- ryu/content-page.php	2013-07-22 15:14:04.000000000 -0700
    +++ /Users/ryan/wc/themes/ryu/content-page.php	2013-09-02 15:41:12.000000000 -0700
    @@ -16,6 +16,7 @@
     		<header class="entry-header">
     			<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
     			<div class="entry-meta">
    +				<?php ryu_entry_meta(); ?>
     				<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
     				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'ryu' ), __( '1 Comment', 'ryu' ), __( '% Comments', 'ryu' ) ); ?></span>
     				<?php endif; ?>
    diff -ru ryu/inc/template-tags.php /Users/ryan/wc/themes/ryu/inc/template-tags.php
    --- ryu/inc/template-tags.php	2013-07-22 15:14:04.000000000 -0700
    +++ /Users/ryan/wc/themes/ryu/inc/template-tags.php	2013-09-02 16:28:46.000000000 -0700
    @@ -166,7 +166,8 @@
    
     if ( ! function_exists( 'ryu_posted_on' ) ) :
     /**
    - * Prints HTML with meta information for the current post-date/time and author.
    + * Prints HTML with meta information for the current and last modified
    + * post-date/time and author.
      */
     function ryu_entry_meta() {
     	if ( is_sticky() && is_home() && ! is_paged() )
    @@ -175,18 +176,28 @@
     			esc_attr( get_the_time() )
     		);
    
    -	if ( 'post' == get_post_type() ) {
    -		printf( __( '<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a></span><span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span>', 'ryu' ),
    -			esc_url( get_permalink() ),
    -			esc_attr( get_the_time() ),
    -			esc_attr( get_the_date( 'c' ) ),
    -			esc_html( get_the_date() ),
    -			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    -			esc_attr( sprintf( __( 'View all posts by %s', 'ryu' ), get_the_author() ) ),
    -			get_the_author()
    +	printf( __( '<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a></span>', 'ryu' ),
    +		esc_url( get_permalink() ),
    +		esc_attr( get_the_time() ),
    +		esc_attr( get_the_date( 'c' ) ),
    +		esc_html( get_the_date() )
     		);
    +
    +	if ( 'page' == get_post_type() && get_the_date() != get_the_modified_date() ) {
    +		printf( __( '<span class="entry-modified-date">updated <a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a></span>', 'ryu' ),
    +			esc_url( get_permalink() ),
    +			esc_attr( get_the_modified_time() ),
    +			esc_attr( get_the_modified_date( 'c' ) ),
    +			esc_html( get_the_modified_date() )
    +			);
     	}
    
    +	printf( __( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', 'ryu' ),
    +		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    +		esc_attr( sprintf( __( 'View all posts by %s', 'ryu' ), get_the_author() ) ),
    +		get_the_author()
    +	);
    +
     	$tags_list = get_the_tag_list( '', __( ', ', 'ryu' ) );
     	if ( $tags_list )
     		echo '<span class="tags-links">' . $tags_list . '</span>';
  2. Michael Cain
    Member
    Posted 10 months ago #

    Hi Ryan,

    We're glad you're enjoying the Ryu theme. Thanks for the suggested patch.

    Part of the WordPress.org Theme Unit Test for pages is that the post date not be displayed. To add it in the ryu_entry_meta() function and then hide it through CSS would seem a little excessive, so unfortunately, we probably won't be merging the patch.

    You are of course welcome to fork Ryu and modify it as you see fit or create a child theme with your changes. Creating a child theme would allow you to modify just a few parts while maintaining the ability to update Ryu without having your changes overwritten.

    Thanks for the input and please let me know if you have any questions.

  3. Ryan
    Member
    Posted 10 months ago #

    understood, thanks for the explanation.

    i love that the official themes generally have well thought out HTML elements, ids, and classes so that users can do heavy customization with CSS alone, so i was surprised that i had to resort to code to get dates on pages. it'd obviously be nice if the theme output them and hid them by default with CSS, so that users could opt in if they wanted.

    i don't think the patch adds much overhead (i'm happy to benchmark if you want), and it seems like hiding by default would pass the unit test...but you all are the pros, so up to you. thanks anyway!

Reply

You must log in to post.

About this Theme

About this Topic