Next/Previous Posts from same category – Single post pages

Posted in: Newspaper
Post count: 45

Hi,

In the single detail pages, there is Previous and Next posts links are given but they are fetching results according to publish date from any category.

We need category specific posts should appear in previous/next post links.

Please help.

Thanks Sanny

Post count: 35449

Hi,

Unfortunately there is no such an options in our theme to can show the category of next / prev posts, sorry!

Thank you for your understanding!

Post count: 1

Hello,
Maybe i’m wrong…
I needed the same thing – for the whole site… – The option is (unfortunately) missing but you can get it through the code

important >> In YOUR CHILD THEME
1 – Create a folder > name it “includes”
2 – Create in this folder a folder > name it “wp_booster”
3 – COPY the file “td_module_single_base.php” (from the “wp-booster” folder in “includes” folder from Newspaper theme) in your child-theme folder “wp_booster”
4 – FIND line 916
$next_post = get_next_post();
$prev_post = get_previous_post();

5 – TURN IT to
$next_post = get_next_post(true);
$prev_post = get_previous_post(true);

It works for me (?)

Post count: 14

This trick seems to work for me, but only for the existing single post page templates. I created a cloud template and added the next/previous element in TD composer, but it seems to call from a different file, rather than “td_module_single_base.php”

If I could find and edit that file, it would really make my day.

Post count: 35449

Hi @ScottLehane,

For cloud module you can try to edit this file wp-content/plugins/td-cloud-library/includes/tdb_module.php hope this will help you!

Thank you!

Post count: 14

I found this snippet of code in wp-content/plugins/td-cloud-library/shortcodes/single/tdb_single_next_previous.php.

It seems to control the next and previous posts for any single post template that has been opened by TD-Composer. If you use the untouched template, the technique mentioned above works for me. But when I switch to a custom template, it starts showing next and previous based on date, regardless of category.

It there a way to edit this code below to make it stay within its category for next and previous posts?

I’d really appreciate any help.

function render( $atts, $content = null ) {
parent::render( $atts ); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)

global $tdb_state_single;
$post_next_prev_data = $tdb_state_single->post_next_prev->__invoke();

$prev_post = !empty( $post_next_prev_data[‘prev_post_url’] ) ? true : false;
$next_post = !empty( $post_next_prev_data[‘next_post_url’] ) ? true : false;

$buffy = ”;

if( $prev_post || $next_post ) {

$post_next_prev_data[‘prev_post_title’] = empty( $post_next_prev_data[‘prev_post_title’] ) ? ” : $post_next_prev_data[‘prev_post_title’];
$post_next_prev_data[‘next_post_title’] = empty( $post_next_prev_data[‘next_post_title’] ) ? ” : $post_next_prev_data[‘next_post_title’];

Post count: 14

My previous post should be deleted so as not to confuse someone trying to follow in my footsteps, but I can’t seem to delete it. I was barking up the wrong tree. I found the code in

/public_html/wp-content/plugins/td-cloud-library/state/single/tdb_state_single.php
Line 1031-1032
$next_post = get_next_post();
$prev_post = get_previous_post();
Should be changed to:
$next_post = get_next_post(true);
$prev_post = get_previous_post(true);

And then the next and previous buttons in your custom cloud templates will also follow the same category.

Post count: 35449

Hi,

Unfortunately this is custom work, you need to do it yourself through the code and if you are not aware of the steps which are needed to take, in this case, please consider hiring a freelancer/developer to help you because we cannot provide custom work at the moment, sorry!

Thank you!

Post count: 4

Calin, I think your theme is really good but Next/Prev in same category should be a standard feature to be honest.
You are referring to custom work but please consider giving a few more options in this module.

Just my thoughts because I’m searching for a solution too.

Post count: 35449

Hi,

I’ve made a note for our developers to implement some more options for Next/Previous, hope this will be implement in the coming updates.

Thank you for your understanding!

Post count: 8

I need something slightly different.

The next/prev comes to a natural end when it reaches the last article. Is there a way to cause it to recycle back to the top?

Thanks
Terry

Post count: 35449

Hello WakefieldWeb,

I do not quite understand what you need to achieve, you need a function back to top ? like the one from this button -> http://prntscr.com/pbl5hf
Please provide some more details.

Thank you!

Post count: 8

Hi Calin,

Sorry … not back to top of page but to story #1. At the moment when it gets to the last story, nothing appears on “Next” but I would like this to go back to story #1.

Thanks
Terry

Post count: 35449

Hello,

Please provide me a link or a screenshot to see what do you mean.

Thank you!

Post count: 8

Hi,

Hope this helps.

Screenshot at http://citizen.wakefield.gov.uk/prev-next.JPG

In this screenshot, you can see “Previous Article” but not “Next Article” because this is the last of the items. What I would like is for “Next Article” link to appear and go back to Article #1. Is that possible?

The site is not live as yet so you won’t be able to see it unless you login as an administrator.

Post count: 35449

Hello,

Now I understand, you want to be like a loop, once that is reach the last article to start again from the first one, unfortunately our theme do not have this function, also this can be achieve only with custom work, if you are interesting on this you can check our custom services from here

Thank you for your understanding!

Viewing 16 posts - 1 through 16 (of 16 total)
The forum ‘Newspaper’ is closed to new topics and replies.