admin管理员组文章数量:1425820
i created custom post type ('Ürünler') with some plugin. And I want to pull all posts from here with category titles. My code doesn't see the custom post type. I'll be happy if you can help me.
$argss = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories=get_categories($argss);
foreach($categories as $category) {
$args=array(
'showposts' => -1,
'category__in' => array($category->term_id),
'caller_get_posts'=>1
);
$posts=get_posts($args);
if ($posts) {
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
foreach($posts as $post) {
setup_postdata($post); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
} // foreach($posts
} // if ($posts
} // foreach($categories`
i created custom post type ('Ürünler') with some plugin. And I want to pull all posts from here with category titles. My code doesn't see the custom post type. I'll be happy if you can help me.
$argss = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories=get_categories($argss);
foreach($categories as $category) {
$args=array(
'showposts' => -1,
'category__in' => array($category->term_id),
'caller_get_posts'=>1
);
$posts=get_posts($args);
if ($posts) {
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
foreach($posts as $post) {
setup_postdata($post); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
} // foreach($posts
} // if ($posts
} // foreach($categories`
Share
Improve this question
edited Jul 4, 2019 at 9:20
Johansson
15.4k11 gold badges43 silver badges79 bronze badges
asked Jul 4, 2019 at 7:36
user171269user171269
1
1 Answer
Reset to default 0Has your custom post type created with the categories? if yes just add 'post_type'=> 'your-custom-post-type' in the args. So for you it will be as below:
$args=array(
'post_type'=> 'Ürünler'
'showposts' => -1,
'category__in' => array($category->term_id),
'caller_get_posts'=>1
);
本文标签: termsI can get posts in all categories But I want to get the custom post type I created
版权声明:本文标题:terms - I can get posts in all categories. But I want to get the custom post type I created 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745347006a2654533.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论