WordPress.org

Forums

Byline
[resolved] How to display an "and" between the last or only two Byline terms (18 posts)

  1. Dan Knauss
    Member
    Posted 10 months ago #

    Here is how to generate bylines like:

    Author 1 and Author 2
    Author 1, Author 2 and Author 3

    You can throw in an Oxford comma too if you want:

    Author 1, Author 2, and Author 3

    There are several ways you could do this within the plugin logic code, but they would complicate the code and mix up logic and presentation more than it already is in WordPress. This simple CSS solution is the best way to go: http://stackoverflow.com/questions/6587807/comma-delimited-lists-with-css-i-want-an-oxford-comma

    Only a few minor changes to the existing plugin code will be necessary:
    http://codex.wordpress.org/Function_Reference/get_the_term_list#Returning_an_HTML_List

    https://wordpress.org/plugins/byline/

  2. mattdu
    Member
    Plugin Author

    Posted 10 months ago #

    Nice. I could integrate into a new version of the plugin. Think there is demand for this feature?

    I imagine designers would want options such as bars, slashes, etc. ...

  3. Dan Knauss
    Member
    Posted 10 months ago #

    Well I wanted it, so I forked your plugin for a child theme I'm working on. :) Have you thought about putting the plugin code on GitHub?

    This ordered list approach makes it very simple to make it look however you want with CSS. It also suggests a way to swap out the list markup for XML tags like <dc:creator> (RSS2 and RDF) and <author>+<name> (Atom).

  4. JT
    Member
    Posted 6 months ago #

    What are the chances of making this so the additional authors that you add link to their archived post? Similar to the plugin below. One thing I can't to work with that plugin is a proper use of commas.

    https://wordpress.org/plugins/co-authors-plus/

  5. Dan Knauss
    Member
    Posted 6 months ago #

    JT - The plugin already works that way. Each name links to their archive page. The plugin code has to be modified to return the names as a list, and then you style the list as a comma separated list. (See my first post.)

  6. JT
    Member
    Posted 6 months ago #

    Sorry, I meant to say "One thing I can't get to work with this plugin" referring to the co-author plus.

    I am now trying to figure out how to get the byline entries to link co authors archive post.

    I saw this from an earlier post:

    Flushing rewrite rules does the trick. I will add that to the next update to the plugin. You can force a rewrite-flush by visiting the Settings/Permalink page in your WP admin.

    I am not sure how to do it. Any help would be greatly appreciated!

  7. Dan Knauss
    Member
    Posted 6 months ago #

    Go to Settings > Permalinks and then save the settings on that page.

  8. JT
    Member
    Posted 6 months ago #

    Thanks that works now!

    Is there a way to populate byline field as you type as there are lot of authors on the blog I maintain. And how would I format the output?

    http://bit.ly/1EGeqH6

  9. Dan Knauss
    Member
    Posted 6 months ago #

    You can edit the bylines just like tags in the posts list or post editor metabox. Like tags if you type "da" it will suggest "Davey Jones" if there is already a Byline with that name.

    You can format the output with your CSS. If you need to change the HTML markup that the plugin outputs, you would have to change the plugin code for how it uses WP's get_the_term_list function. (See the two links in my first post in this thread.)

  10. crochetedowl
    Member
    Posted 2 months ago #

    I added the CSS. Now, what exactly do we change in byline.php, and how do we change it in order to get this?

    If I simply change $author = get_the_term_list( $post->ID, 'byline', '', ', ', '' ); to $author = get_the_term_list( $post->ID, 'byline', '<li>', '</li><li>', '</li>' );, then I get a normal list. How do I introduce the ul class?

  11. Dan Knauss
    Member
    Posted 2 months ago #

    If you haven't edited your page templates yet, you'll need to do that now to enclose the the_author function in <ul> tags.

  12. crochetedowl
    Member
    Posted 2 months ago #

    For some reason, this isn't working for me.

    Even though it's supposed to be inline, it kicks the author data to the next line.

    There are also commas after all of the entries for some reason. The cite is ignoring all of the "last-child" CSS rules.

  13. crochetedowl
    Member
    Posted 2 months ago #

    Okay, sorry. It obeys the "last child" rules now.

    It still knocks down a line, though. It looks like this:

    By

    author information | categories

  14. Dan Knauss
    Member
    Posted 2 months ago #

    That sounds like it's just a matter of getting your CSS right. Can you provide a live link so I can take a look?

  15. crochetedowl
    Member
    Posted 2 months ago #

    My site is under a Coming Soon page. I'd be willing to set up a Subscriber account for you so that you can see the page, but if it's necessary, I guess that I could temporarily remove the Coming Soon page.

  16. Dan Knauss
    Member
    Posted 2 months ago #

    Either way is fine, just email me.

  17. crochetedowl
    Member
    Posted 2 months ago #

    Okay. I sent you a message.

  18. Dan Knauss
    Member
    Posted 2 months ago #

    Thanks, I just replied.

    What you're dealing with is a theme that has its own functions to create a byline using WP's get_the_author(), and it's still trying to do that. The Byline plugin just replaces the output of get_the_author() and not the additional markup your theme's byline and postmeta functions generate.

    You can do a quick and dirty fix with CSS (display: none;) or override and replace the theme's byline function (remove_action and add_action). You could also write some custom page templates in a child theme that override the parent, but this would mean you won't get the benefit of future updates to the parent unless you merge the future changes back into your own.

    The CSS solution is actually not too bad, but no matter which way you handle this, you really need to create a child theme for your custom CSS, theme functions, etc.

Reply

You must log in to post.

About this Plugin

  • Byline
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic