打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Wordpress – Use custom fields for filtering posts | iMod
userphoto

2009.08.14

关注

How often do you filter pages usingcategories, tags and so forth, but what if this isn’t enough? Entercustom fields. We’ve all used custom fields to add images or speciallittle bits to posts, but what about using them for displaying postswith similar custom field values?

Check this code out..

<?php query_posts(’meta_key=car&meta_value=ford’); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

It’s honestly as simple as that. “car” refers to the custom field key and “ford” refers to the value.

It’s as simple as that!

Useful? Definitely!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
The Complete Guide To Custom Post Types
php-根据WooCommerce统一费率送货方式的自定义字段计算添加送货时间
WordPress 技巧:给每个页面都设置不同的菜单
WordPress无刷新分类筛选以及分页的文章列表 | WordPress大学
WordPress 添加自定义栏目面板
介绍WordPress 的10个小技巧
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服