Skip Navigation

[Resolved] Split: Display on Single post page "previous" and "next" for custom post type template – hide next button on last

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 13 replies, has 3 voices.

Last updated by Waqar 1 year, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2658359

Hi Minesh,

Thank you for your help, I am making progress in resolving my issues
I need help with the 4 issues below :

1) I have not manage to set the condition to hide the last post (When Next post doesn't exist) ... respectively hide the First post (when the Previous post does'nt exists), could you help me with that?

2) I would like to prefix the post's author link name with the word "By" how can I do that since the Author is a shortcode [wpv-post-author format="link" meta="name" item="[ts_get_adjacent_post_id]"]

3) the display is also a bit odd since I had to use for the Title linked shortcode "[wpv-post-previous-link]" respectively [wpv-post-next-link] ... It has by design the small chevron.... How can I change it (remove, replace or modify that chevron)

4) I have managed to find another interresting resolved issue (from your colleague Waqar) to use intead the featured image with the respective post link. But it doesn't indicate where should use that code (I have pasted below) to get it working... That code is also very interesting since I can tweak the featured image size!!!
How can I modify the previous from code ?

https://toolset.com/forums/topic/prev-next-pages-using-featured-image/
-----------------
// previous post link

[wpv-post-featured-image size="custom" width="100" height="100" crop="true" item="[ts_get_adjacent_post_id previous='true']"]

// next post link

[wpv-post-featured-image size="custom" width="100" height="100" crop="true" item="[ts_get_adjacent_post_id]"]

-----------------

#2658361

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1) I have not manage to set the condition to hide the last post (When Next post doesn't exist) ... respectively hide the First post (when the Previous post does'nt exists), could you help me with that?

2) I would like to prefix the post's author link name with the word "By" how can I do that since the Author is a shortcode [wpv-post-author format="link" meta="name" item="[ts_get_adjacent_post_id]"]
===>
I will handle the above issues with this ticket.

Can you please share problem URL as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2658401

What will happen to the other questions

3) the display is also a bit odd since I had to use for the Title linked shortcode "[wpv-post-previous-link]" respectively [wpv-post-next-link] ... It has by design the small chevron.... How can I change it (remove, replace or modify that chevron)

4) I have managed to find another interresting resolved issue (from your colleague Waqar) to use intead the featured image with the respective post link. But it doesn't indicate where should use that code (I have pasted below) to get it working... That code is also very interesting since I can tweak the featured image size!!!
How can I modify the previous from code ?

#2658403

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

To display the By - I've just added the prefix word "By" as you can see as given under:

By: [wpv-post-author format="link" meta="name" item="[ts_get_adjacent_post_id]"]

To hide the next box when you are on the last post - I've wrapped the block you are currently displaying using the conditional block as you can see with the following screenshot: hidden link
=> hidden link

And with the conditional block I've checked the custom shortcode value [ts_get_adjacent_post_id] is not empty.

Can you please confirm it works as expected. Then we will move to your last two questions.

#2661391

Hi Minesh,
I have managed to hide the "Next" box but for the last Post , it is not working to hide the "Previous" post since there is no previous post (of course it should not be [ts_get_adjacent_post_id] is not empty) .
Question: what shortcode should I use to test the previous post?

#2661705

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'm not sure why you added the blocks that displays previous and next links two times.

You will have to wrap the previous and next link block to check for not empty.

When you check for previous link make sure you should use the shortcode as: [ts_get_adjacent_post_id previous='true']

#2663059

Hi Minesh,
Regarding your question: " I'm not sure why you added the blocks that displays previous and next links two times."

My answer > If the next link is empty I do not want to display the "box" at all... therefore I am aiming to hide the whole row and display a row with only one box (the left one or the right one)

However, I have not manage to right the proper test to show or hide the row...

Case 1: For the latest post, the "double" boxes should be hidden and only the "previous box"(the right box) below should be displayed
Case 2: For the first post, the "double" boxes should also be hidden and only the "next box"(the left box) below should be displayed
Case 3: All the other case, the 'none-edge" posts should display both the left box (Previous) and right box (Next) AND of course hide the single box rows.

For some reason I cannot find the right logic test.

#2664631

Hi,

Minesh is on vacation till end of this month, so I'll be following up on this ticket.

The admin access link has been expired. Can you please share a new access link and also the link to an example page where the shortcode and conditional display is not working, as expected.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2664697

Sorry I forgot to indicate where I have issues
1) The latest post is not showing the previous post
hidden link

2) the fist post is showing the previous post when it shouldn't
hidden link

Note for 2) I believe the wrong widget is displayed as I have created 3 widget row for all 3 situation the two edge cases and the case when there is a previous and a next post.

#2665031

The access link worked thank you.

I was able to login to the admin area, but the content template edit screen couldn't load. There are several errors in the browser's console.

The latest compatibility releases for the Toolset plugins for compatibility with WordPress 6.4 are not updated on the website, yet.

Can you please update all plugins to the latest versions and also deactivate any extra plugins which are not needed for the layout and functionality of this content template? You can activate them back, once this troubleshooting for the conditional statements has been completed.

#2665393

Hi Waqar,

Thank you for coming back to me on my issue.
the site "postprod.poleconfin.org" I am using is a copy of the live site, so I have made a new copy of the live site and replicated the customisation I had done so far on the "postprod.poleconfin" site on THIS NEW Site = "hidden link"

The issue is still there and I have granted toolset admin access like on the previous site (that is the only way I have to update the plugins) - Let's forget about old site and focus on this new site copy.
I do have installed the plugins "Health Check & Troubleshooting"... you can disable any plugins you need (also I could share with you the "new debug extract"

hidden link

#2665743

Thank you for sharing this staging website.

I can access the front-end but not the back-end. It just shows the error page with 'Not available.' message.
( screenshot: hidden link )

Can you please check the access link again?
( I've set the next reply as private )

#2665765

Hi Waqar,
I am so sorry I had a firewall settings still "ON". It is now disable
I do hope you are now able to login.

My issue is really about the toolset conditional settings... for the edge cases: First post and Last post

Best regards

#2666509

Thank you for waiting.

During testing and reviewing the setup, I was able to achieve what you were planning, without using separate rows and conditional blocks.

1. I removed the conditional blocks and kept only a single section that contained both boxes for the next and previous posts.

2. Next, added custom CSS classes in section settings of parent and enclosed section blocks, so that they can be identified:
( example screenshot: hidden link )

- bottom-pagintion-section (parent section)
- bottom-pagintion-section-prev (child of the parent section, in the left column )
- bottom-pagintion-section-next (child of the parent section, in the right column )

3. In custom JS editor of the content template, included this custom script, that hides each prev/next child section, if the 'prev/next' text is not available:


jQuery(document).ready(function( $ ) {
	if ($('.bottom-pagintion-section .bottom-pagintion-section-prev:contains("PREVIOUS PAPER:")').length == 0) {
		$(".bottom-pagintion-section .bottom-pagintion-section-prev").css("visibility", "hidden");
	}
});

jQuery(document).ready(function( $ ) {
	if ($('.bottom-pagintion-section .bottom-pagintion-section-next:contains("NEXT PAPER:")').length == 0) {
		$(".bottom-pagintion-section .bottom-pagintion-section-next").css("visibility", "hidden");
	}
});

You can see this working in the different cases:

First:
hidden link
( no previous post box )

Normal:
hidden link
( both boxes )

Last:
hidden link
( no next post box )

#2666633

Hello waqar,

I have looked at your code (pretty advanced solution). It works like a charm!!!
My issue is resolved you may close this issue as resolved.
Thank you for your support