Support » Theme: OceanWP » Next/Prev links on Custom Post Types

  • Hi, I can’t get to work Next/Prev links on Custom Post Types in OceanWP theme. I’m coming from Divi and I have a Custom Post Type called Projects (default Divi feature) when I open one of these posts there are no Next/Prev links… Anyone have an idea to solve this?

    • This topic was modified 2 years, 3 months ago by David Klhufek.

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Theme Author oceanwp

    (@oceanwp)

    Hello, you need to do this via the child theme, because the next/prev links is by default for posts.

    Yes, I use child theme oceanwp-child-theme-master, there is a file singular.php but I can’t find the place to reflect I need navigation for projects. Any idea?

    Theme Author oceanwp

    (@oceanwp)

    Hi, in your partials folder into your child theme, create a “single” folder, in this folder, create a layout-CPT.php (replace CPT by the name of your custom post type), in this file you can control what you want in front end for this custom post type, take example of the layout file in the single folder of the parent theme.
    Then, add a next/prev file also by taking example of the next-prev.php file into the single folder of the parent theme. You will need to edit this file for your CPT, so remove the “‘post’ != get_post_type()” code because you want the next/prev for your projects post type.

    I tested what you wrote above, but it was not worked. Lately, I tried to copy original singular.php to new child file single-project.php then I add navigation code from Divi and viola it’s working now well. Anyway thank you for your time, we can close it.

    Theme Author oceanwp

    (@oceanwp)

    Hi, yes it is a good solution too 🙂

    udidol

    (@udidol)

    Hi,

    I have the same problem – I have a CPT on my site (called “chapters”). In single CPT posts, it’s not outputting tags, meta, related posts or next/prev links. Just the post image, title and content. They all display properly in standard posts (“post” post type).

    I took the following steps already:
    1. I created a /partials/single/ directory in my child theme oceanwp-child
    2. I took the layout.php file from the parent theme, copied it into the newly created directory in the child theme, and named it layout-chapters.php

    What am I missing? What else do I need to do in order for all the layout elements to work in my CPT?

    Thanks for your help

    Theme Author oceanwp

    (@oceanwp)

    Hello @udidol, open your layout-chapters.php file in your text editor and add a code like this:

    <article id="post-<?php the_ID(); ?>">
    
    	<?php
    	// Get posts format
    	$format = get_post_format();
    	$format = $format ? $format : 'thumbnail';
    			
    	// Featured image
    	get_template_part( 'partials/single/media/blog-single', $format );
    
    	// Title
    	get_template_part( 'partials/single/header' );
    
    	// Meta
    	get_template_part( 'partials/single/meta' );
    
    	// Content
    	get_template_part( 'partials/single/content' );
    
    	// Tags
    	get_template_part( 'partials/single/tags' );
    
    	}
    
    	// Social Share
    	if ( OCEAN_EXTRA_ACTIVE ) {
    
    		do_action( 'ocean_social_share' );
    
    	}
    
    	// Next/Prev
    	get_template_part( 'partials/single/next-prev' );
    
    	// Author Box
    	get_template_part( 'partials/single/author-bio' );
    
    	// Related Posts
    	get_template_part( 'partials/single/related-posts' );
    
    	// Comments
    	comments_template(); ?>
    
    </article>

    Then if you want to have the Next/Prev link for your CPT, replace:

    get_template_part( 'partials/single/next-prev' );

    by:

    get_template_part( 'partials/single/next-prev-chapters' );

    Go get the next-prev.php file in oceanwp/partials/single/, add it in the same path into your child theme, rename it to “next-prev-chapters.php”, open it in your text editor and replace “$term_tax” at line 27 by your own taxonomy, for example if your toxonomy tag name is “chapters_tags”, replace the variable with that name.

    • This reply was modified 2 years ago by oceanwp.
    udidol

    (@udidol)

    Hey,

    I already created a next-prev-chapters.php in my oceanwp_child/partials/single/ folder.

    I tried replacing $term_tax with chapters, like this:

    'taxonomy' => chapters,

    It didn’t work. I also tried 'taxonomy' => 'chapters', and that didn’t work either.

    Any ideas?

    udidol

    (@udidol)

    Oh, wait.
    I think I did something wrong in layout-chapters.php.
    I’ll look at it later tonight and see… Sorry for the false alarm.

    • This reply was modified 2 years ago by udidol.
    • This reply was modified 2 years ago by udidol.
    Theme Author oceanwp

    (@oceanwp)

    Hi, in the “taxonomy”, you need to add your category post type, for example, “chapters_category” not the CPT “chapters”.

    udidol

    (@udidol)

    But what if I want the previous/next post links to work on all of the CPT posts and not only one category?
    Would I have no choice but to give all of these posts the same category?

    udidol

    (@udidol)

    Hi,
    I think I will just use previous_post_link(); and next_post_link(); in the layout-chapters.php template instead of OceanWP’s method… I tried it and it does what I need.

    Thank you for your help!!
    I would have given you a 5 star review again if I could 🙂

    • This reply was modified 2 years ago by udidol.
    Theme Author oceanwp

    (@oceanwp)

    Hello, yes you found the solution 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Next/Prev links on Custom Post Types’ is closed to new replies.