Как вывести все посты из определенного post_type?
Есть вот такой post_type:
function interior_custompost_type_projects() { $labels = array( 'name' => ( 'Проекты' ), 'singular_name' => ( 'Проекты' ), ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'interior_projects' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array( 'interior_projects', 'title', 'editor', 'thumbnail' ) ); register_post_type( 'interior_projects', $args ); } add_action( 'init', 'interior_custompost_type_projects' );
Пол часа мучился, искал, но ответа так и не нашел.
<?php // $interior_projects1 = get_post_type('interior_projects); // $interior_projects2 = get_posts($interior_projects1); $myposts = get_posts( 'interior_projects', 20 ); foreach ($myposts as $project_categories1) { ?> <div class="cbp-item identity logos"> <a href="img/works-1-big.jpg" class="cbp-caption cbp-lightbox"> <div class="cbp-caption-defaultWrap"> <img src="img/works-1.jpg" alt=""> </div> <div class="cbp-caption-activeWrap"> <div class="cbp-l-caption-alignLeft"> <div class="cbp-l-caption-body"> <div class="cbp-l-caption-title"><?php the_title(); ?></div> <div class="cbp-l-caption-desc">Описание</div> </div> </div> </div> </a> </div> <?php } ?>
И на что ты полчаса потратил?
Читай документацию: https://wp-kama.ru/function/get_posts
Так вроде ничего сложного же.