Php 如何在WordPress上获取文章的自定义文件?
此方法Php 如何在WordPress上获取文章的自定义文件?,php,wordpress,Php,Wordpress,此方法get\u posts()返回所有字段 但我需要获取自定义字段,例如,我只想获取id和title及其类别名称。我认为通过传递参数,您可以获得所需的内容 $args = array( 'numberposts' => -1, // -1 is for all 'post_type' => 'movie', // or 'post', 'page' 'orderby' => 'title', /
get\u posts()
返回所有字段
但我需要获取自定义字段,例如,我只想获取
id
和title
及其类别名称。我认为通过传递参数,您可以获得所需的内容
$args = array(
'numberposts' => -1, // -1 is for all
'post_type' => 'movie', // or 'post', 'page'
'orderby' => 'title', // or 'date', 'rand'
'order' => 'ASC', // or 'DESC'
);
// Get the posts
$posts = get_posts($args);
// If there are posts
if($posts){
// Loop the posts
foreach ($posts as $post){
var_dump($mypost->ID); // you have ID here
}
}
欢迎访问stackoverflow.com。请花些时间阅读帮助页面,特别是“我可以在这里问什么主题?”和“我应该避免问什么类型的问题”部分。另外,请参加本次参观,并阅读如何提出好的问题。最后,请学习如何创建一个最小的、完整的、可验证的示例。你能再次阅读我的问题吗?我需要得到自定义字段数组<代码>选择ID、标题…此文章的类别,不包含内容和其他字段