0

I'm using the_title() to show the title of a custom post type, but it's not working; the title does not show.

get_header();
$wp_query = new WP_Query();
$wp_query -> query('post_type=press&showposts=20');
while ($wp_query->have_posts()) : 
    $wp_query->the_post(); ?>
    <div class="press-item">
        <div class="press-img"><?php the_post_thumbnail('medium');?></div>
        <div class="press-content">
            <div class="press-title"><?php the_title(); ?> </div>
            <div class="press-excerpt"><?php the_excerpt(); ?> </div>
        </div>
    </div>
<?php endwhile;
get_footer();

1 Answer 1

2

Try this as your query:

$args = array(
    'post_type'      => 'press',
    'posts_per_page' => 20
);

$wp_query = new WP_Query( $args );

while // etc. 

Also you could try:

<div class="press-title"><?php echo get_the_title(); ?> </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.