admin管理员组文章数量:1303327
I'm pretty new to wordpress, I'm making an API call so it returns a certain number of posts with the same category, the meta fields and thumbnails. How can I return only the content before the READ MORE? I read that I can use the get_extended function but I can't figure out for the life of me where to put it. Here's the code at the moment:
register_rest_route('mypage', 'recipes/(?P<quantity>[0-9]+)', array(
'methods' => WP_REST_Server::READABLE,
'callback' => function($request) {
$post_type = 'recipe';
$pages = get_posts([
'post_type' => $post_type,
'numberposts' => $request['quantity']
]);
if ( empty( $pages ) ) {
return [];
}
$recipe = [];
$meta_fields = apply_filters('hook', null)[$post_type]['fields'];
foreach ($pages as $page) {
$page = (array)$page;
$page['fields'] = get_post_meta($page['ID']);
$page['thumbnail'] = get_the_post_thumbnail_url($page['ID']);
$recipes[] = $page;
}
return $recipes;
},
'permission_callback' => '__return_true'
));
本文标签: phpShow content before more block
版权声明:本文标题:php - Show content before more block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741758331a2396246.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论