Is it possible to show an image after the number?

front page Forums Community Is it possible to show an image after the number?

This topic contains 2 replies, has 2 voices, and was last updated by Avatar Nathan Pinno 6 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3950
    Avatar
    Nathan Pinno

    Hi folks,

    Just wanted to know if it was possible to show an image instead of a word after the number of credits are shown, and if so, how would I do so?

    Thanks,
    Nathan P.

    #3955
    Avatar
    WPExperts

    Hi.

    You can add an image via the mycred_format_creds filter which is used before points are displayed with the suffix or prefix you have.

    Example 1 – Add image directly after the format number:
    Any prefix or suffix used under settings are also inserted.

    add_filter( 'mycred_format_creds', 'adjust_how_points_look', 10, 3 );
    function adjust_how_points_look( $string, $amount, $mycred  ) {
    	return $string . '<img src="https://yoursite.com/image.jpg" alt="" />';
    }
    

    Example 2 – Add image directly after the unformated points value:
    Any prefix or suffix set under your settings are not shown here.

    add_filter( 'mycred_format_creds', 'adjust_how_points_look', 10, 3 );
    function adjust_how_points_look( $string, $amount, $mycred  ) {
    	return $amount . '<img src="https://yoursite.com/image.jpg" alt="" />';
    }
    
    #3999
    Avatar
    Nathan Pinno

    Thanks Gabriel for the code! The second one was just what I was looking for!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Is it possible to show an image after the number?’ is closed to new replies.

11