How can I stop the featured image from displaying in my custom post types queries?
my code when quering
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$loop = new WP_Query( array(
'post_type' => array(
'weddings',
'e_shoots_and_couples',
开发者_开发问答 'kids_familiy',
'portraits',
'other_shoots'
),
'posts_per_page' => 10,
'paged' => $paged
) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?><div id="slider-date"><?php echo get_the_date(); ?></div>
<div class="entry-content">
<?php the_content();
/*$content = get_the_excerpt();
$postOutput = preg_replace('/<img[^>]+./','', $content);
echo $postOutput;*/
?>
</div>
<?php endwhile; ?>
Thanks
Please take a look as the link add theme support--Post Thumbnails
You can set thumbnail support for specific post types or all post type by using the add_theme_support function in functions.php file of your theme.
This feature enables post-thumbnail support for a Theme. This feature became available with Version 2.9. Note that you can optionally pass a second argument with an array of the post types for which you want to enable this feature.
add_theme_support('post-thumbnails');
To enable only for Posts:
add_theme_support( 'post-thumbnails', array( 'post' ) );
Or only Pages:
add_theme_support( 'post-thumbnails', array( 'page' ) );
Enable for Posts and "movie" post type but not for Pages.
add_theme_support( 'post-thumbnails', array( 'post', 'movie' ) );
This feature must be called before the init hook is fired. That means it needs to be placed directly into functions.php or within a function attached to the after_setup_theme hook:
For custom post types, you can also add post thumbnails using the register_post_type function as well.
精彩评论