小编ank*_*eye的帖子

如何将ACF值拉入自定义帖子类型存档

所以我的问题是我刚刚创建了一个自定义帖子类型,并创建了几个帖子来配合这个.我在我创建的模板single-post_type.php中使用ACF字段.这些显示在单个帖子上很好,但我需要在单个帖子页面上显示的一些ACF字段值显示在自定义帖子索引上.我试过寻找答案,但似乎无法找到我正在寻找的东西.

作为参考,这是我注册自定义帖子类型的代码:

// Add new post type for Available Homes
add_action('init', 'available_homes');
function available_homes() 
{
$available_homes_labels = array(
    'name' => _x('Available Homes', 'post type general name'),
    'singular_name' => _x('Available Home', 'post type singular name'),
    'all_items' => __('All Available Homes'),
    'add_new' => _x('Add New Listing', 'recipes'),
    'add_new_item' => __('Add New Listing'),
    'edit_item' => __('Edit Listing'),
    'new_item' => __('New Listing'),
    'view_item' => __('View Listing'),
    'search_items' => __('Search in Available Homes'),
    'not_found' =>  __('No listings found'),
    'not_found_in_trash' => __('No listings found in trash'), …
Run Code Online (Sandbox Code Playgroud)

php custom-post-type advanced-custom-fields

6
推荐指数
1
解决办法
1万
查看次数