开发者

Link to page with custom posts?

开发者 https://www.devze.com 2023-03-15 19:50 出处:网络
I\'ve created this theme with some custom post types called projects and events. I now want to link to a \"archive page\" all the posts with that post type. H开发者_JAVA技巧ow is that possible?

I've created this theme with some custom post types called projects and events.

I now want to link to a "archive page" all the posts with that post type. H开发者_JAVA技巧ow is that possible?

Thanks!


try wp_query class you can cusomize it with the post type. read more here http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters

then you may do so with a condition to change the code in achhive page from:

if (have_posts()) : while (have_posts()) : the_post();

to:

$cat_posts = new WP_Query($query_string."post_type=projects");
if ($cat_posts->have_posts()) : while($cat_posts->have_posts()) : 
    $cat_posts->the_post();
0

精彩评论

暂无评论...
验证码 换一张
取 消