Displaying a read more link after excerpt, with Autonav

    January 27th, 2013 by bill

    Here is an example AutoNav filter that will display a “Read More” link, for posts in a list.

    We invoke this as follows:

    [autonav display="posts,list,title,nothumb,excerpt" count=5 postid="category:autonav-plugin" class="readmore"]

    Live demo form the posts on this site:

    Put this code in your theme’s functions.php:

    function autonav_excerpt_readmore($html, $class, $pic, $attr) {
      if ($attr['display'] == 'posts' && $attr['class'] == 'readmore') {
        if (strlen($pic['excerpt'])) {
          $html .= '<a href="' . $pic['permalink'] . '">' . __('Read more') . '...</a>';
        }
      }
      return $html;
    }
    
    add_filter('autonav_create_list_item', 'autonav_excerpt_readmore', 
       50, 4);
    

    The filter is added with priority 50, so it will be inserted after the excerpt. The function only inserts the “Read More” link if the class="readmore" parameter is used in the AutoNav invocation, and only if posts are listed, and only if the post actually had an excerpt.

    NOTE: The above was originally asked here.

    Grand Falls, Arizona

    April 23rd, 2012 by bill

    The Grand Falls of the Little Colorado River, northern Arizona

    Panoramic View
    A few metres upstream the river is at ground level
    The falls are taller than Niagara, although there was just a trickle of water this day

    Standing on a corner in Winslow, Arizona