Archived topic
CPT single post
6 replies · Started by Jasper on September 24, 2016
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.
Maybe this could help you:
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
'after' => '</div>',wp_link_pages
) );
?>
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();
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 ?
my cpt is called 'werk' and the file is single-werk.php
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
thank you Jean!