如何调用wordpress自定义post类型的页面
How to call wordpress custom post type page
我在 WordPress 中创建了一个自定义 post 类型,我还将其单独的两个页面设置为单页-acme_product.php、存档-acme_product.php 但问题是当我上传 post 来自自定义 post 键入它的显示 index.php
这是我的函数代码
function new_post_type_wp(){
register_post_type('acme_product',
array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('Product')
),
'public' => true,
'has_archive' => true,
)
);
}
add_action('init','new_post_type_wp');
请告诉我如何将我的自定义 post 导航到特定的自定义页面 我还阅读了 wordpress codex 它非常有帮助我按照它的方法但是我的问题是一样的请帮助我
您是否尝试过在特定页面中使用此自定义 post 类型?
$args = array( 'post_type' => 'acme_product', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
我在 WordPress 中创建了一个自定义 post 类型,我还将其单独的两个页面设置为单页-acme_product.php、存档-acme_product.php 但问题是当我上传 post 来自自定义 post 键入它的显示 index.php
这是我的函数代码
function new_post_type_wp(){
register_post_type('acme_product',
array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('Product')
),
'public' => true,
'has_archive' => true,
)
);
}
add_action('init','new_post_type_wp');
请告诉我如何将我的自定义 post 导航到特定的自定义页面 我还阅读了 wordpress codex 它非常有帮助我按照它的方法但是我的问题是一样的请帮助我
您是否尝试过在特定页面中使用此自定义 post 类型?
$args = array( 'post_type' => 'acme_product', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;