php - 如何让元素只出现在移动主页上(wordpress)

标签 php html css wordpress

前几天我在这里问了一个关于在我的移动主页上获取类别的问题。我得到了这段代码,它起作用了:

<?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/

相关文章:

javascript - 提交没有表单的输入

javascript - 基于javascript的 echo 下拉

html - 如何让三个 div 标签自动对齐以响应用户的视口(viewport)?

javascript - 多个图像的 context.drawImage 最终导致 FireFox 崩溃

html - 如何让背景和页面一样长?

html - 在 Bootstrap 上导入谷歌字体

php - 有没有办法保存 MySQL 连接供以后使用?

PHP-修改分页排序

html - 带有 `position: absolute` 的内部按钮将放置在 table 外面

javascript - 使用 jQuery 在 Chrome 中获取元素的宽度