Skip Navigation

[Gelöst] how get the id of the previous post for [wpv-post-next-link]?

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Setup links to parent post, the link text is a custom field value of parent post.
I wrote a shortcode [next-post-id] to get the id of the next post.

function shortcode_next_post_id ($atts)
{
   global $post;
   $next_post = get_next_post();
   if (empty ($next_post))
        return 0;
   return $next_post->ID;
}
add_shortcode('next-post-id', 'shortcode_next_post_id');

Solution:
Since you have already got the post ID of next post with custom shortcode [next-post-id], so you can setup the link manually with HTML code, for example:

<a href="[wpv-post-url id=[next-post-id]]"> [types field='rs-brandname' id='[next-post-id]'][/types]</a>

Please make sure you have already registered the custom shortcode name in the Toolset setting page:
Dashboard->Toolset-> Front-end content
option "Third-party shortcode arguments", fill the custom shortcode name: next-post-id

Relevant Documentation:

This support ticket is created vor 6 Jahre, 7 Monate. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Luo Yang vor 6 Jahre, 7 Monate.

Assisted by: Luo Yang.

Author
Artikel
#568430

I am trying to:
Show next post with [wpv-post-next-link format="%%LINK%% »" link="Next post: %%TITLE%%"]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-next-link

I don´t want to see the %%TITLE%%, but want to so a custom field (rs-brandname) of the next post instead.

So i wrote a shortcode [next-post-id] to get the id of the next post.

function shortcode_next_post_id ($atts)
{
   global $post;
   $next_post = get_next_post();
   if (empty ($next_post))
        return 0;
   return $next_post->ID;
}
add_shortcode('next-post-id', 'shortcode_next_post_id');

I expected to see a link for next post with brandname with this shortcode:

[wpv-post-next-link format="%%LINK%% "" link="[types field='rs-brandname' id='[next-post-id]'][/types]"]

But i just always see the brandname of current post.

What works fine is [types field='rs-brandname' id='[next-post-id]'][/types]

next-post-id is insert in Toolset/setting as third party shortcode.
What i am doing wrong?

#568446

Dear Mario,

Since you have already got the post ID of next post with custom shortcode [next-post-id], so you can setup the link manually with HTML code, for example:

<a href="[wpv-post-url id=[next-post-id]]"> [types field='rs-brandname' id='[next-post-id]'][/types]</a>

Please make sure you have already registered the custom shortcode name in the Toolset setting page:
Dashboard->Toolset-> Front-end content
option "Third-party shortcode arguments", fill the custom shortcode name: next-post-id

#568543

Thank you so much.

#568577

You are welcome

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.