• Resolved Nate

    (@kapitol)


    Hi Vee,

    Your theme has been very easy for me to modify thus far. I do have one issue. I am trying to add a call to grab an author’s avatar/gravatar image to the ‘bootstrapBasicPostOn’ section.

    Each attempt I make to solve this myself ends up with nothing showing up. This is my modified code.

    if (!function_exists('bootstrapBasicPostOn')) {
    	/**
    	 * display post date/time and author
    	 *
    	 * @return string
    	 */
    	function bootstrapBasicPostOn()
    	{
    //		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
            $time_string = '';
    		if (get_the_time('U') !== get_the_modified_time('U')) {
    			$time_string .= '';
    //			$time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
    		}
    
    		$time_string = sprintf($time_string,
    			esc_attr(get_the_date('c')),
    			esc_html(get_the_date()),
    			esc_attr(get_the_modified_date('c')),
    			esc_html(get_the_modified_date()),
                esc_attr(get_the_author_meta( 'ID' ), 32 )
    		);
    
    //		printf(__('<span class="posted-on">Written by %1$s</span><span class="byline"> Written by %2$s</span>', 'bootstrap-basic'),
    		printf(__('<span class="byline"> Written by %2$s</span>', 'bootstrap-basic'),
    			sprintf('<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
    				esc_url(get_permalink()),
    				esc_attr(get_the_time()),
    				$time_string
    			),
    			sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
    				esc_url(get_author_posts_url(get_the_author_meta('ID'))),
    				esc_attr(sprintf(__('View all posts by %s', 'bootstrap-basic'), get_the_author())),
    				esc_html(get_the_author())
    			)
    		);
    	}// bootstrapBasicPostOn
    }

Viewing 1 replies (of 1 total)
  • Theme Author vee

    (@okvee)

    You should use get_avatar() function to get author’s avatar/gravatar.
    https://codex.www.ads-software.com/Function_Reference/get_avatar
    More references for use.

    if (!function_exists('bootstrapBasicPostOn')) {
    	/**
    	 * display post date/time and author
    	 *
    	 * @return string
    	 */
    	function bootstrapBasicPostOn()
    	{
    //		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
            $time_string = '';
    
    //		printf(__('<span class="posted-on">Written by %1$s</span><span class="byline"> Written by %2$s</span>', 'bootstrap-basic'),
    		printf(__('<span class="byline"> Written by %1$s</span>', 'bootstrap-basic'),
    			sprintf('<span class="author vcard"><a href="%1$s" title="%2$s">%3$s</a></span> %4$s',
    				esc_url(get_author_posts_url(get_the_author_meta('ID'))),
    				esc_attr(sprintf(__('View all posts by %s', 'bootstrap-basic'), get_the_author())),
    				esc_html(get_the_author()),
    				get_avatar(get_the_author_meta( 'ID' ))
    			)
    		);
    	}// bootstrapBasicPostOn
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Gravatar/Avatar’ is closed to new replies.