Skip Navigation

[Resuelto] how get the id of the previous post for [wpv-post-next-link]?

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 7 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Etiquetado: ,

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Luo Yang hace 7 años, 2 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#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