评论添加自定义表情包

评论添加自定义表情包

将下载好的文件解压到网站根目录。

在functions.php中添加如下代码:

//自定义表情路径和名称
function custom_smilies_src($src, $img){return get
').'/img/smilies/' . $img;}
add_filter('smilies_src', 'custom_smilies_src', 10
if ( !isset( $wpsmiliestrans ) ) {
  $wpsmiliestrans = array(
    ':?:' => 'ow_question.gif',
        ':razz:' => 'ow_razz.gif',
        ':sad:' => 'ow_sad.gif',
        ':evil:' => 'ow_evil.gif',
        ':!:' => 'ow_exclaim.gif',
        ':smile:' => 'ow_smile.gif',
        ':oops:' => 'ow_redface.gif',
        ':grin:' => 'ow_biggrin.gif',
        ':eek:' => 'ow_surprised.gif',
        ':shock:' => 'ow_eek.gif',
        ':???:' => 'ow_confused.gif',
        ':cool:' => 'ow_cool.gif',
        ':lol:' => 'ow_lol.gif',
        ':mad:' => 'ow_mad.gif',
        ':twisted:' => 'ow_twisted.gif',
        ':roll:' => 'ow_rolleyes.gif',
        ':wink:' => 'ow_wink.gif',
        ':idea:' => 'ow_idea.gif',
        ':arrow:' => 'ow_arrow.gif',
        ':neutral:' => 'ow_neutral.gif',
        ':cry:' => 'ow_cry.gif',
        ':mrgreen:' => 'ow_mrgreen.gif',
  );
}

最后一步在评论模板的中引入smiley.php

<p class="emoji-box">
    <?php include(THEME_TEMPLATE_PATH . '/img/smiley.php'); ?>
</p>
[/code_expand]
评论
:broken_heart: :confounded: :flushed: :frowning: :grinning: :heart: :kissing_heart: :mask: :pensive: :rage: :relaxed: :scream: :smile: :smirk: :sob: :stuck_out_tongue_closed_eyes: :stuck_out_tongue_winking_eye: :wink: