Tagged: x
-
AuthorPosts
-
May 12, 2016 at 8:27 pm #988867
rekluseParticipantHey guys, another question:
I am trying to tweak the author bylines on all post and category pages.
http://everyoneisright.com/media/
So, instead of saying “By Alan Watkins”, I actually just want it to say “Alan Watkins”. How can I eliminate the “by”?
Related question: I am using the Co-Authors Plus plugin so I can associate more than one name with the post (the majority of our content features recorded dialogues with 2 or more people.) I am trying to figure out how to get both names to display in the byline. I know your support of third-party plugins is limited, but is there any documentation you might be able to point me toward to get this working?
Thank you!
May 12, 2016 at 10:54 pm #989069
Nabeel AModeratorHi there,
Thanks for writing in! Please add the following jQuery script in your Customizer via Appearance > Customize > Custom > Edit Global Javascript
jQuery(document).ready(function($){ $('.p-meta span:first-child').each(function(){ $(this).html("Alan Watkins"); }); });Displaying two author names could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.
Thanks for understanding. Take care!
May 17, 2016 at 7:34 pm #996354
rekluseParticipantSo sorry it took me a minute to get back to this, and thank you for your assistance.
Looking at the code above, it looks like this will actually replace all instances of the word “by” in all bylines across the site to “Alan Watkins”. I actually don’t want to do this — I just want to get rid of the word “by” before the author name.
So, we have these three posts:
TITLE 1
by This Guy / February 21, 2016TITLE 2
by That Guy / March 17th, 2016TITLE 3
by Other Guy / April 3rd, 2016I would like the byline to read like this instead (obviously the post authors are being selected within the post itself):
TITLE 1
This Guy / February 21, 2016TITLE 2
That Guy / March 17th, 2016TITLE 3
Other Guy / April 3rd, 2016Is there a variation of the above code that will do this for me?
Thanks again!
May 17, 2016 at 10:38 pm #996676
DarshanaModeratorHi there,
I see you’re using Ethos stack. Please follow this approach instead.
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Then edit the file functions.php in your child theme, using a code editor such as notepad or notepad++ and add the following code inside the file.
// Entry Meta // ============================================================================= if ( ! function_exists( 'x_ethos_entry_meta' ) ) : function x_ethos_entry_meta() { // // Author. // $author = sprintf( ' %1$s %2$s</span>', __( '', '__x__' ), get_the_author() ); // // Date. // $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); // // Categories. // if ( get_post_type() == 'x-portfolio' ) { if ( has_term( '', 'portfolio-category', NULL ) ) { $categories = get_the_terms( get_the_ID(), 'portfolio-category' ); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_term_link( $category->slug, 'portfolio-category' ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%1$s %2$s', __( 'In', '__x__' ), trim( $categories_output, $separator ) ); } else { $categories_list = ''; } } else { $categories = get_the_category(); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%1$s %2$s', __( 'In', '__x__' ), trim( $categories_output, $separator ) ); } // // Comments link. // if ( comments_open() ) { $title = apply_filters( 'x_entry_meta_comments_title', get_the_title() ); $link = apply_filters( 'x_entry_meta_comments_link', get_comments_link() ); $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() ); if ( $number == 0 ) { $text = __( 'Leave a Comment' , '__x__' ); } else if ( $number == 1 ) { $text = $number . ' ' . __( 'Comment' , '__x__' ); } else { $text = $number . ' ' . __( 'Comments' , '__x__' ); } $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>', esc_url( $link ), esc_attr( sprintf( __( 'Leave a comment on: “%s”', '__x__' ), $title ) ), $text ); } else { $comments = ''; } // // Output. // if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>', $categories_list, $author, $date, $comments ); } } endif;Save the changes and head over to your Blog page.
Hope that helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-988867 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
