Support » Plugin: Byline » Getting to the descriptions

  • Resolved dsolimini

    (@dsolimini)


    First, I love this plugin right now. Implementing co-authors plus was driving me batty and this is a godsend. Thank you.

    A brief question… and please note that while I have a background in SQL and ASP, PHP is not my native language and it’s been a while since I dug into a coding project.

    How do I display the description field? At the bottom of my posts, I’d like to loop through each byline and spit out something like:

    About Bob Smith
    Bob Smith is an awesome guy. He does things and stuff.

    About Andrew Anderson
    Andrew is the director of important things at large company.

    etc.

    Assistance is appreciated.

    Best,
    Dave

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author mattdu

    (@mattdu)

    That’s a great idea. I envisioned that when I wrote this but have not gotten around to coding that. BUT you’re in luck, I figured it out:

    $terms = get_terms("byline");
                         $count = count($terms);
                         if ( $count > 0 ){
                             echo "<ul>";
                             foreach ( $terms as $term ) {
                               echo "<h6>About " . $term->name . "</h6>";
                               echo "<p>" . $term->description . "</p>";
                             }
                             echo "</ul>";
                         }

    You can replace the HTML markup for anything you prefer and add class names, etc.

    I would drop this in your single.php template or inside whatever handles the display of post-content.

    You can see this magic at work here: http://mattdulin.com/tdcx/duis-sed-nisl-aliquam/

    Plugin Author mattdu

    (@mattdu)

    Ignore the UL and replace with a DIV or however else you want to wrap this author listing. If you use UL then you will also need to add
    a LI tag before each H6 and after the closing P tag… you know the drill.

    Thread Starter dsolimini

    (@dsolimini)

    You, sir, have made my night. Worked perfectly. And now that I understand get_terms(), I can do additional things with this. Thank you again for such a solid piece of work.

    Hi Matt,

    This is precisely the plugin I’ve been looking for our new blog! I love its simplicity and its features, except I’m having a hard time getting the author descriptions to show at the end of my post.

    Granted, I’m a little over my head, but I think I found which PHP file (content-single.php) contains the entry-content and get_the_author for my theme (Catch Box). As you can see here, I’m having a hard time trying to figure out where in the content-single.php file to place the code you referenced in your previous post. Do I paste it in between the existing PHP code? Do I replace some of the existing code with your code?

    Again, I apologize for the junior-level question, but I’d love to figure out how to make this work for our blog. Any insights you can offer would be tremendous. Thanks!

    Plugin Author mattdu

    (@mattdu)

    The code needs to be inside a php tag.

    To be safe, rather than deleting your old code, you can comment out the old code by placing two forward slashes after the php opening tag but before each line of code, so it might look something like:

    <?php //old code here;
           //more old code ();
           //last line of old code;
           //You can add a comment here, to remind you why there is new code below
           $terms = get_terms("byline");
              $count = count($terms);
              if ( $count > 0 ){
                 echo "<ul>";
                    foreach ( $terms as $term ) {
                         echo "<h6>About " . $term->name . "</h6>";
                         echo "<p>" . $term->description . "</p>";
                                                 }
                  echo "</ul>";
                               }
    ?>

    Thanks, Matt! You’re a lifesaver!

    I’ve got the code to dynamically display the author’s name and bio, but it also looks like it displays all of the byline authors I’ve created (I’ve created two), even when I’ve only assigned one byline author in the post builder (down near the tags section). The byline(s) also appear on posts that do not have a byline author identified.

    Any thoughts?

    Thanks!

    I added this to my single.php, but then it shows all author and descriptions on all pages. Same issue as pwocken.

    It’s a test site, but you can see it live here – http://www.hereismysite.info/monster-santa/

    <?php //old code here;
           //more old code ();
           //last line of old code;
           //You can add a comment here, to remind you why there is new code below
           $terms = get_terms("byline");
              $count = count($terms);
              if ( $count > 0 ){
                 echo "
    <ul>";
                    foreach ( $terms as $term ) {
                         echo "<h6>About " . $term->name . "</h6>";
                         echo "<p>" . $term->description . "</p>";
                                                 }
                  echo "</ul>
    ";
                               }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    This month old topic has been resolved.

    Plugin Author mattdu

    (@mattdu)

    OK, this post revealed a flaw in my previous code.

    Replace this line:
    $terms = get_terms("byline");

    With this line:
    $terms = get_the_terms($post->ID, 'byline');

    Matt, your demo site using the 2014 theme displays an extra linked author icon at the head of the byline list since the user-author link is still being displayed with the linked text (your name) removed. That original user-author link ends up enclosing all your byline links:
    <span class="entry-date"><a href="http://mattdulin.com/tdcx/duis-sed-nisl-aliquam/" rel="bookmark"><time class="entry-date" datetime="2014-03-25T03:50:45+00:00">March 25, 2014</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="http://mattdulin.com/tdcx/author/tdcadmin/" rel="author"><a href="http://mattdulin.com/tdcx/byline/firstname-lastname/" rel="tag">Firstname Lastname</a>, <a href="http://mattdulin.com/tdcx/byline/lorem-ipsum-guy/" rel="tag">Lorem Ipsum Guy</a>, <a href="http://mattdulin.com/tdcx/byline/secondname-lastname/" rel="tag">Secondname Lastname</a>, <a href="http://mattdulin.com/tdcx/byline/thirdname-lastname/" rel="tag">Thirdname Lastname</a></a></span></span></div>

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Getting to the descriptions’ is closed to new replies.