给WordPress文章循环加上CSS类方便实现各种页面布局

Posted in:
Update time:2015-05-24

We offer WordPress Themes and Plugins Custom Development Services

This site has long undertaken WordPress themes, plugins, WooCommerce-based store mall development business. We have 10 years of experience in WordPress development, if you want to Developing Websites with WordPress, please contact WeChat: iwillhappy1314 or email: amos@wpcio.com for inquiries.

4 thoughts on “给WordPress文章循环加上CSS类方便实现各种页面布局

  1. 你好!请教一下,怎么给循环输出的5个li 按照顺序加入指定顺序的class呢? $classname[] ={small, small, large, big, wide} 把这五个class类加入的5个li中!谢谢

    1. 循环中加入计数器i,i初始值值为0,然后echo $classname[$i];$i++;这样,第一个就是$classname[0],第二个就是classname[1],以此类推。

      1. 参考这篇文章:https://www.wpzhiku.com/the-deffrient-of-wp_reset_postdata-and-wp_reset_query/

  2. 谢谢搞定!还有个问题在首页我用下面的代码通过ID获取文章,需要怎么修改才能不影响主循环的文章呢?我调用后多少篇,首页就少多少篇文章…
    $posts = get_posts("numberposts=5&post_type=any&include=14233,14236,1372,1425,1417");
    这代码影响了首页的显示…

发表回复

Your email address will not be published. 必填项已用 * 标注

*