许多人也都开始对自己的站点进行了移动设备适配/优化,也有大部分朋友但考虑到有一些适合PC端读者阅读的内容可能不适合移动端读者,所以给大家提供一个WordPress 短代码实现移动设备上内容不可见的方法。 利用下面的短代码,可以实现发布的内容在移动设备不可见。 function hide_mobile_shortcode($atts, $content = ”) { if (wp_is_mobile() === true) { $content = ”; } return $content; } add_shortcode(‘hm’, ‘hide_mobile_shortco […]
标签:短代码
给WordPress的下载链接自动添加图片
有时想让你的下载链接直接变成漂亮的图片按钮,也可以通过WordPress的短代码功能来实现: 在你的functions.php文件里添加: /**紫色部分就是下载链接的图片 */ function download($atts, $content = null) { return ‘<a href=”‘.$content.'” rel=”external nofollow” target=”_blank” title=”download-下载地址”> <img src=”http://www.hzlzh.com/up/download.gif” border=”0″ /></a>’;} add_s […]
给WordPress添加FLV播放器
实现方法: 下载 flvplayer.swf 播放器:http://www.hzlzh.com/up/flvplayer.swf 把播放器放到 当前使用主题目录 即 wp-content/theme/****; 在主题的 functions.php 中添加如下代码即可; /**FLV player */ function flvplayer($atts, $content=null){ extract(shortcode_atts(array(“width”=>’460′,”height”=>’330′),$atts)); return ‘<embed width=”‘.$width.'” height=”‘.$ […]
给WordPress添加Flash音乐播放器
今天从自立博客那看到这个通过主题functions.php添加短代码实现Flash音乐播放器,方法如下: 首先:下载flash播放: 然后:上传到 wp-content/theme/主题目录/ 最后:在Wordpress 在用主题的 functions.php 中间位置 添加如下函数: /**添加 flash player */ function myplayer($atts, $content=null){ extract(shortcode_atts(array(“auto”=>’no’,”loop”=>’no’),$atts)); return ‘<embed src=”‘.get_bloginfo(“tem […]