admin管理员组文章数量:1430548
For SEO purposes I use my URLs like this:
site/parent/child/
Currently I have pages like this:
site/parent/
site/page-1/
site/page-2/
site/page-3/
I want to list some of those page-1, page-2 etc. pages on site/parent/ I thought the best way to do this is to add a custom field to those.
So is there a better way to do this? If not, how can I wp list pages based on custom fields?
For SEO purposes I use my URLs like this:
site/parent/child/
Currently I have pages like this:
site/parent/
site/page-1/
site/page-2/
site/page-3/
I want to list some of those page-1, page-2 etc. pages on site/parent/ I thought the best way to do this is to add a custom field to those.
So is there a better way to do this? If not, how can I wp list pages based on custom fields?
Share Improve this question asked Apr 24, 2019 at 9:33 Markus HansenMarkus Hansen 311 bronze badge1 Answer
Reset to default 1Function wp_list_pages()
accepts arguments from get_pages()
function. To list pages filtered by custom field use meta_key
and meta_value
in parameters array. A list of accepted parameters can be found here and here.
wp_list_pages([
'meta_key' => 'your_meta_KEY',
'meta_value' => 'searched_value', // optional
]);
meta_value
is not mandatory, if you skip it, a list of pages with any value of the custom field will be returned.
本文标签: List pages by custom field
版权声明:本文标题:List pages by custom field? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745558148a2663309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论