• Hell,

    I have create custom post type as ‘project’ and create many some post of that type.I use bellow query to fetch custom post

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    query_posts(array(
            'post_type' => 'project',
           	'post_status' => 'publish'
        ) );
    	while (have_posts()) : the_post(); ?>
            <h2><a>"><?php the_title(); ?></a></h2>
            <p><?php echo get_the_excerpt(); ?></p>
    <?php endwhile;

    This query display all post but when click on any link that time give error not page found.

    ulr path as bellow

    localhost/wordpress_demo?p=50

    please what is wrong?

Viewing 1 replies (of 1 total)
  • I think error here so please replace
    <h2>”><?php the_title(); ?></h2>
    To
    <h2><?php the_title(); ?></h2>

    Other wise use this code

    <?php
    $args = array( 'post_type' => 'project');
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    	echo get_the_title();
    	echo get_the_excerpt();
    endwhile;
    ?>
    
Viewing 1 replies (of 1 total)

The topic ‘custom post type single post not display’ is closed to new replies.