Всем привет! Создал кастомный post_type и приложил к ним фото. Осталось вывести их, но не получается достать эти картинки.
Создаю post_type:
function archirio_custompost_type_projects() {
$labels = array(
'name' => 'Home Latest Projects',
'singular_name' => 'Home Latest Projects',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'Home Latest Projects' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail' ),
);
register_post_type( 'home_latest_projects', $args );
}
add_action( 'init', 'archirio_custompost_type_projects' );
Вот вывожу данные через цикл:
$args = array( 'post_type' => 'home_latest_projects');
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) { ?>
<pre><?php print_r($attachment); ?></pre>
<?php echo get_the_post_thumbnail(); ?>
<?php }
}
wp_reset_postdata();
Выдаёт всё, но не url фото:
WP_Post Object
(
[ID] => 157
[post_author] => 1
[post_date] => 2018-07-31 13:20:26
[post_date_gmt] => 2018-07-31 07:20:26
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => 157
[to_ping] =>
[pinged] =>
[post_modified] => 2018-07-31 13:20:26
[post_modified_gmt] => 2018-07-31 07:20:26
[post_content_filtered] =>
[post_parent] => 0
[guid] =>
wp/?post_type=home_latest_projects&p=157
[menu_order] => 0
[post_type] => home_latest_projects
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
Добавляю фото так: