前几天我在这里问了一个关于在我的移动主页上获取类别的问题。我得到了这段代码,它起作用了:
<?php
// Feed PHP with the information you want to show, in our case: a certain category = use of the id, number = amount of posts to show
$catquery = new WP_Query( 'cat=3&posts_per_page=1' );
// Let WordPress run the loop for you
while($catquery->have_posts()) : $catquery->the_post();
?>
<!--Inside the loop, you can use the WP template tags to show the stuff you want, like author, exerpt of the post etc. -->
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
<?php endwhile; ?>
<?php // Don't forget to reset the query (clean the data after it is finished) ?>
<?php wp_reset_query(); ?>
我目前通过自定义 css 将其设置为仅显示在移动设备上,但我正在尝试弄清楚如何让该元素仅显示在移动设备主页上,而不显示在后续页面上。
谢谢!!非常感谢您的帮助!
最佳答案
为要在移动设备中显示的元素编写您的 css
@media only screen
and (min-device-width: 320px)
and (max-device-width: 480px)
and (-webkit-min-device-pixel-ratio: 2) {
/* you css for element*/
}
关于php - 如何让元素只出现在移动主页上(wordpress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38272435/