Skip Navigation

[Resolved] Can next and previous short code links include a class?

This thread is resolved. Here is a description of the problem and solution.

Problem:

I'd like to add a class to wpv-post-previous-link and wpv-post-next-link but can's seem to do it. I've tried adding a class on the outside of the shortcode to create a button but then I have a button that has no content when it reaches the start or the end.

Solution:

As a workaround, you can wrap those shortcode in a HTML element, for example:

https://toolset.com/forums/topic/can-next-and-previous-short-code-links-include-a-class/#post-1725409

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-previous-link

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-next-link

This support ticket is created 4 years, 5 months ago. 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.

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 8 replies, has 2 voices.

Last updated by larryB-3 4 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1724653
Screen Shot 2020-08-01 at 4.00.43 PM.jpg

I'd like to add a class to wpv-post-previous-link and wpv-post-next-link but can's seem to do it. I've tried adding a class on the outside of the shortcode to create a button but then I have a button that has no content when it reaches the start or the end.

Is there a way to style
[wpv-post-previous-link format="« %%LINK%%"]

I tried this and it works well except when it's the first post or the last post. I
<div class="prev-next">[wpv-post-previous-link format="« %%LINK%%"]</div>

I tried this and it doesn't work.
[wpv-post-previous-link format="« %%LINK%%" class="prev-next"]

#1725409

Hello,

According to our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-previous-link
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-next-link

Both shortcodes do not support adding CSS class feature.

As a workaround, you can wrap those shortcode in a HTML element, for example:

<span class="my-pre-link">[wpv-post-previous-link format="" %%LINK%%" link="Previous post: %%TITLE%%"]</span>
<span class="my-next-link">[wpv-post-next-link format="" %%LINK%%" link="Previous post: %%TITLE%%"]</span>

Then setup CSS codes, like this:

.my-pre-link a{
/** here setup your CSS codes**/
}
.my-next-link a{
/** here setup your CSS codes**/
}
#1725593

Wrapping them in CSS when you are creating a button means that the shape/background color of the button will still persist on the screen even when the shortcode returns null. 🙁

#1726383

It is a custom CSS issue, please provide a live problem page URL, where I can see the problem:
the shape/background color of the button will still persist on the screen even when the shortcode returns null.

I need to test it in my Chrome browser.

#1727029

Here you go:

hidden link

#1727735

In your case, you can try below CSS codes:

div.prev-next:empty{display:none;}

More help:
hidden link

#1728563

Lou that completely worked on this page for the the previous one as you can see here.
hidden link

However it didn't work on the final one for the next one as you can see here.
hidden link

I would have thought it would have taken care of both previous and next buttons. Can you assist on this last part?

#1728879

The CSS selector ":empty" works only when there isn't any content within that DIV tag, but your page outputs some blank spaces in the div tag, for example:

<div class="e777-8 x-bar-content-area prev-next">
  </div>

hidden link

You will need to edit that page, try to remove those blank spaces and test again, for example:

<div class="e777-8 x-bar-content-area prev-next"></div>

See the document I mentioned above:
hidden link

#1729263

My issue is resolved now. Thank you!