所以我在这里发现了这个问题:Proper Way to Remove Thumbnail Links In Gallery 看起来有一个很好的答案,但我如何才能使其仅在用户使用移动浏览器时适用,或者至少在屏幕具有一定宽度时适用?
现在,我正在使用原生的wordpress图库,当你点击拇指时,它会带你进入更大的图像。如果您使用的是手机或小型浏览器,我不希望这样做。
所以我在这里发现了这个问题:Proper Way to Remove Thumbnail Links In Gallery 看起来有一个很好的答案,但我如何才能使其仅在用户使用移动浏览器时适用,或者至少在屏幕具有一定宽度时适用?
现在,我正在使用原生的wordpress图库,当你点击拇指时,它会带你进入更大的图像。如果您使用的是手机或小型浏览器,我不希望这样做。
第一件事是第一件事
您可以使用移动插件创建专门针对移动用户的网站
我通常使用WPtouch
要检查用户是否正在使用移动浏览器/代理,您还可以使用功能。。。这意味着您需要不时更新用户代理。。。
Here is an example function from eric stokes site:
http://erikastokes.com/php/how-to-test-if-a-browser-is-mobile.php
您可以将该函数嵌入到函数中。php或将其包含到函数中。php
然后可以检查并创建条件链接,例如:
<?php
if(is_mobile()) {
echo \'<a href="http://www.mobile.com">i am using mobile</a>\';
}
else {
echo \'<a href="http://www.desktop.com">i am using a desktop computer</a>\';
}
?>
。Example relating to the answer you found here:
$image = wp_get_attachment_image( $id, $size, false );
// if it\'s set to not show the image link
if(isset($attr[\'link\']) && (\'none\' == $attr[\'link\']) && !is_mobile() ){
// then just show the image
echo $image;
} else {
// else show the image wrapped in a link
$link = wp_get_attachment_url($id);
echo "<a href=\\"$link\\">$image</a>";
}
希望这有帮助<干杯,萨吉夫从短代码输出中删除所有不需要的内容。
<小时>
add_shortcode( \'gallery\', \'modified_gallery_shortcode\' );
function modified_gallery_shortcode($attr)
{
$output = gallery_shortcode($attr);
if( wp_is_mobile() )
{
// only keep these tags
$whitelist = \'<img><div><figure><li>\';
// strip the rest
$output = strip_tags( $output, $whitelist);
}
return $output; // final html
}
自从Wordpress从3.4.2升级到3.5以来,Wordpress Mobile Edition一直无法运行。我在插件的支持页面上留下了一个支持请求,但两周内没有收到回复。我可能不得不断定插件作者不再支持这个插件。我知道这个问题可能会违反指导原则,但有没有现成的替代方法来使用Wordpress Mobile Edition?也许这不一定是一个插件,但可能是一个Wordpress黑客。我想保留卡灵顿手机的定制版。