Prev / Next Buttons with Dynamic Content Issue

Hey,
I’m not sure how to describe it exactly.

I use buttons with dynamic content to display the “previous” and “next” post within a single post.

This is within the buttons:

Link:
{{{dc:post:permalink post=“prev”}}
Text:
{{{dc:post:title post=“prev”}}

and

Link:
{{{dc:post:permalink post=“next”}}
Text:
{{{dc:post:title post=“next”}}

I have inserted these two buttons into a content block.
And I show the content block with the following code in the function.php

function custom_post_arrows() {
if ( is_single() ) {
echo do_shortcode(’[cs_gb id=XXX]’);
}
}
add_action(‘x_before_the_content_end’, ‘custom_post_arrows’);

This works quite well.

Unfortunately, the client starts with 2 posts at the beginning.

Problem 1:
If you look at the last post entered, the Next button is not filled and only the button design appears, but not the dynamic content text.
This is also because there is no new post I guess?
Is there a workaround for a loop, so that you can click through all posts with next and previous?

Problem 2:
If you click on the first, i.e. oldest post, both buttons are not filled at all.

I hope you can help me out?
(red / green colours for demonstration only)

Thanks!

prev-next-button

Hello @ronaldo304,

Thanks for writing in!

Please be aware that the arrow will only be displayed if there isn’t any post title or post link because that is the last or very post already. You will need a custom css so that the buttons will be hidden if there is no longer a post (next/previous) to link with. To get that resolve, please edit your global block and insert this custom css:

.x-anchor-button[href=""]{
    display: none;
}

If nothing is helping, provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Regards.

Hi,
this CSS solution works perfectly. Sometimes it is so simple.
For the second problem, I’ll give you a safe note.
Thank you.

Hey @ronaldo304,

The buttons work if you add an older post to your “akademie” post. I’m currently not able to replicate your exact setup in my test site so would you mind testing adding more posts and change the date of a post so that it becomes the oldest post.

In my test site, I checked the oldest post and prev and next buttons work or have a permalink so we need to see what exactly is causing this issue.

Please also try deactivating all third-party plugins and custom functions maybe one of them is influencing the prev and next permalinks.

Thanks.

Hey, thanks for the quick reply.

I have now switched the date on both posts. It’s still on. The “next” button (not the button but the dynamic content) is missing for the oldest entry.

In addition I have created 2 new posts. (These two test posts are set to private mode for logged in users)
One with the newest date, one with the oldest.
Also the same here.
At the post with the oldest date, the “next” button is still missing.

The prev-buttons are working fine everywhere.

If you deactivate the “display:none” CSS code for the buttons at the last post (above “Zurück zur Übersicht”), you can see that no dynamic content (in this case the secondary text) is loaded at the “next” button. And the link refers to its own URL.

In summary, this means that all buttons and functions work correctly, except the “next” button in the oldest post.

Please can you have a look at them again?

Hey @ronaldo304,

Thanks for testing. Yes, this is weird. Did you also test for plugin conflicts as asked previously? What was the result?

If you can’t test since its a live site, copy your live site to a staging server and give us Staging WordPress Admin and FTP access and we’ll continue testing in staging so that there’s no risk of breaking your live site.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.