WordPress.org

Ready to get started?Download WordPress

Forums

Author Avatars List
[resolved] Link under widget (6 posts)

  1. Tara Rotten
    Member
    Posted 3 years ago #

    Hey,

    This plug in is amazing!

    Im really new to php / code so need some help.

    I have a 6 avatars in my sidebar using this widget, below the avatars i would like to add a link to a page showing all the users, ie 'view all bloggers' anyway i can add this? my side bar uses dropdown(hide reveal) widgets so i cant just add a link in a text widget under the author widget help pleasee

  2. Ben
    Member
    Plugin Author

    Posted 3 years ago #

    The plugin applies a bunch of (undocumented) filters on the different templates used for generating the output, which you might be able to use. All hooks are in Userlist.class.php (search for the use of the "apply_filters" function).

    For your case you probably want to use the "aa_userlist_template" filter. You can use it by adding for example the following to your theme's functions.php:

    <?php
    function aa_userlist_add_link_to_all( $template ) {
      $url_link = '/all-bloggers';
      $url_text = 'View all bloggers';
      $template .= '<span class="all_bloggers_link"><a href="' . $url . '">' . $text . '</a></span>';
      return $template;
    }
    add_filter('aa_userlist_template', 'aa_userlist_add_link_to_all');
    ?>

    I haven't tested it but this is how it should work in principle; you obviously need to adjust $url_link and $url_text, and add respective styling for span.all_bloggers_link to your theme...

    The default value for $template is '<div class="author-list">{users}</div>' and above function simply adds a link to the end of it.

    Hope this helps.

    Ben

  3. Tara Rotten
    Member
    Posted 3 years ago #

    AMAZING!! works so good.

    any way i can place it in the author-list div as im using a dropdown widget plugin which hides and reveals widgets on a loop and right now my v'iew all' link is outside the hide show area

    Thanks so much for the help

  4. Ben
    Member
    Plugin Author

    Posted 3 years ago #

    Try this version (which overrides the plugin's default template):

    <?php
    function aa_userlist_add_link_to_all( $template ) {
      $url_link = '/all-bloggers';
      $url_text = 'View all bloggers';
      $template = '<div class="author-list">{users} <span class="all_bloggers_link"><a href="' . $url . '">' . $text . '</a></span></div>';
      return $template;
    }
    add_filter('aa_userlist_template', 'aa_userlist_add_link_to_all');
    ?>
  5. Tara Rotten
    Member
    Posted 3 years ago #

    Thanks starting to get the hang of it just trying to figure out how to only have this 'view all' link work in the widget and not on my page displaying all my bloggers

  6. Ben
    Member
    Plugin Author

    Posted 3 years ago #

    Good point, I didn't think of that... I don't think there's an easy way to change the template only for one instance and not the other, but you could use css styling to hide or show it respectively.

    Add something like the following to your theme's css:

    .main_content .author-list .all_bloggers_link {
      display: none;
    }

    You need to change .main_content to a class that actually exists in your theme (and which is attached to the main content area).

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic