WordPress.org

Support

Support » How-To and Troubleshooting » Custom post type single page

Custom post type single page

  • I have created a custom post type called kundcase.
    I have a file called: kundcase.php where the first kundcase is shown with following code:

    // Set the page to be pagination
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    // Query Out Database
    $wpbp = new WP_Query(array( 'post_type' => 'kundcase', 'posts_per_page' =>'1', 'paged' => $paged ) );

    In the widget I created a want to show the four latest cases, and that works fine as well.
    Theese cases are linked to a single page like: domain/kundcase/customer and there is where the problem begins.
    What do I do to get the same layout as the kundcase.php.
    I have tried to create a single-kundcase.php but it is ignored.

    The code that echos the cases in widget:

    // Set the page to be pagination
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    
    // Query Out Database
    $wpbp = new WP_Query(array( 'post_type' => 'kundcase', 'posts_per_page' =>'10', 'paged' => $paged ) );
    ?>
    
    <?php
    // Begin The Loop
    if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post();
    ?>
    
    <?php
    ?>
    <li>
    
    <?php // Output the title of each kundcase item ?>
    								<h2><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></h2>
    <p><?php echo get_the_excerpt(); ?>
    </p>
    <p><a href="<?php the_permalink(); ?>">Läs mer...</a></p>
    								</li>

    So what do I do? Is it not possible to combinate kundcase.php and single-kundcase.php? Or do I use the wrong way/code for the output?

    Would be greatful for some help with this.

    /Malin

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post type single page’ is closed to new replies.
Skip to toolbar