I need to get the URL for Custom post type Thumbnail, My custom post type name is slider. I have defined on functions.php:
/* Custom post type */
add_action('init', 'slider_register');
function slider_register() {
$labels = array(
'name' => __('Slider', 'post type general name'),
'singular_name' => __('Slider Item', 'post type singular name'),
'add_new' => __('Add New', 'portfolio item'),
'add_new_item' => __('Add New Slider Item'),
'edit_item' => __('Edit Slider Item'),
'new_item' => __('New Slider Item'),
'view_item' => __('View Slider Item'),
'search_items' => __('Search Slider'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/image/slider.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail')
);
register_post_type( 'slider' , $args );
flush_rewrite_rules();
}
add_filter("manage_edit-slider_columns", "slider_edit_columns");
function slider_edit_columns($columns){
$columns = array(
"cb" => "<input type='checkbox' />;",
"title" => "Portfolio Title",
);
return $columns;
}
My code is:
<!-- Slider -->
<?php
$args = array(
'post_type'=> 'post',
'post_status' => 'publish',
'order' => 'DESC',
'tax_query' => array(
array(
'post-type' => array('post', 'slider')
)
)
);
$query = new WP_Query($args);
if( $query -> have_posts() ) {
?>
<div id="slider_area">
<div class="slider">
<a href='#' class="prev"><i class="fa fa-angle-double-left"></i></a>
<a href='#' class="next"><i class="fa fa-angle-double-right"></i></a>
<ul class="slider_list">
<?php
while($query->have_posts()) : $query->the_post();
if(has_post_thumbnail()) { ?>
<li>
<?php the_post_thumbnail(); ?>
</li>
<?php }
elseif($thumbnail = get_post_meta($post->ID, 'image', true)) { ?>
<li>
<img src="<?php echo $thumbnail; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" />
</li>
<?php } endwhile;
?>
</ul>
</div>
</div>
<?php } ?>
What is the problem? Could anyone help me? Thank you for your helps.
get_the_post_thumbnail($post->ID)
instead ofthe_post_thumbnail()