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
);