WordPress.org

Ready to get started?Download WordPress

Forums

Custom post type single page (4 posts)

  1. mahlinksi
    Member
    Posted 1 year ago #

    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

  2. IMICreation
    Member
    Posted 1 year ago #

    use get_permalink();

  3. mahlinksi
    Member
    Posted 1 year ago #

    Thank your for your reply.
    I have solved the problem.
    I guess there were a misspelling - everything is ok now.

  4. Asad
    Member
    Posted 1 year ago #

    Hi! mahlinksi. here is same problem with me. please help.

    I have created custom post type too .called project. i made single-project.php. it's working great in localhost "wamp". but not working live why that's heaping to me please help

    check out link here
    click thumbnail to check single-project.php

Topic Closed

This topic has been closed to new replies.

About this Topic