简体   繁体   English

WordPress主题:在手机上显示不同数量的帖子?

[英]Wordpress theme: show different number of posts on mobile?

I tried making the title as descriptive as possible... What I was wondering was; 我试图使标题尽可能地具有描述性。 if it is possible to show a different number of posts on the front page on a mobile/handheld device.. 如果可以在移动/手持设备的首页上显示不同数量的帖子。

I guess you could do some if else for the query, and user-agent would be involved somehow. 我想您可以为查询执行其他操作,并且用户代理会以某种方式涉及。 but I was wondering if there is some bulletproof solution? 但我想知道是否有防弹解决方案? so that no browser or mobile/handheld would reach the full version? 这样浏览器或移动/手持设备都无法达到完整版本?

If you are using a separate mobile theme in Wordpress, you can edit the loop in that particular theme to show only however many posts you want. 如果您在Wordpress中使用单独的移动主题,则可以编辑该特定主题中的循环以仅显示所需的任何帖子。

This is the ideal way of doing it. 这是执行此操作的理想方法。

It seems as if you want to use the same Wordpress theme for both desktop and mobile, and only want to change the number of posts displayed. 似乎您要在桌面和移动设备上使用相同的Wordpress主题,而只想更改显示的帖子数。 I wouldn't recommend this. 我不推荐这个。 Instead use a separate theme and have Wordpress display that different theme based on the user agent. 而是使用单独的主题,并让Wordpress根据用户代理显示不同的主题。

A plugin like the one I've linked to below might help you out. 像我在下面链接到的插件那样的插件可能会对您有所帮助。

http://wordpress.org/extend/plugins/wp-mobile-detector/ http://wordpress.org/extend/plugins/wp-mobile-detector/

You can detect whether or not the user is on a mobile device on your wordpress site with the script at http://detectmobiledevices.mobi . 您可以使用http://detectmobiledevices.mobi中的脚本来检测用户是否在wordpress网站上的移动设备上。 As the article says, simply add this to your themes folder. 如文章所述,只需将其添加到主题文件夹。

include('mobile_device_detect.php');
$mobile = mobile_device_detect();

You can find the original article here at: http://www.wprecipes.com/how-to-detect-mobile-visitors-on-your-wordpress-blog 您可以在以下位置找到原始文章: http : //www.wprecipes.com/how-to-detect-mobile-visitors-on-your-wordpress-blog

If you don't have a seperate mobile theme this is probably the way you'd want to go. 如果您没有单独的移动主题,那么这可能就是您想要的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM