[Resolved] CPT single post

Home Forums Support [Resolved] CPT single post

Home Forums Support CPT single post

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #229134
    Jasper

    Still learning about CPT. I used the Easy Content Types plugin to create the cpt and the single-cpt.php and archive.cpt.php files.

    However how do i create the function to go to the next or previous single.cpt page. These are not displayed on thebottom of the single.cpt page.

    #229135
    Jean Paiva
    Developer

    Maybe this could help you:

    <?php
      wp_link_pages( array(
        'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
        'after'  => '</div>',wp_link_pages
      ) );
    ?>
    #229136
    Jasper

    I added your code to the single.cpt.php but no luck, maybe it is in the wrong spot?

    here is the whole file:

    <?php
    /**
     * The Template for displaying all single posts.
     *
     * @package GeneratePress
     */
     
    // No direct access, please
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    get_header(); ?>
    
    	<div id="primary" <?php generate_content_class();?>>
    		<main id="main" <?php generate_main_class(); ?>>
    		<?php do_action('generate_before_main_content'); ?>
    		<?php while ( have_posts() ) : the_post(); ?>
    
    			<?php get_template_part( 'content', 'single' ); ?>
    <?php
      wp_link_pages( array(
        'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
        'after'  => '</div>',wp_link_pages
      ) );
    ?>
    			<?php
    				// If comments are open or we have at least one comment, load up the comment template
    				if ( comments_open() || '0' != get_comments_number() ) : ?>
    					<div class="comments-area">
    						<?php comments_template(); ?>
    					</div>
    			<?php endif; ?>
    
    		<?php endwhile; // end of the loop. ?>
    		<?php do_action('generate_after_main_content'); ?>
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php 
    do_action('generate_sidebars');
    get_footer();
    #229141
    Jean Paiva
    Developer

    Sorry Jasper, the snippet that I sent you was wrong, had some crazy string lost in the middle. :/

    But I’m seeing that you are using GP default single.php and this template (content-single.php) already use this function that I posted before.

    What is the name of the file you are using for this post type? single-ctp.php ?

    #229143
    Jasper

    my cpt is called ‘werk’ and the file is single-werk.php

    #229158
    Jean Paiva
    Developer

    Jasper I figured this out, you’ll need to create another template file (content-werk.php) and a small edit on your single-werk.php:

    Check this gist, have two files and should work: LINK FOR GIST

    #229217
    Jasper

    thank you Jean!

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.