Skip Navigation

[Résolu] Date in superscript format

This support ticket is created Il y a 7 années et 2 mois. 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 2 réponses, has 3 voix.

Last updated by Luo Yang Il y a 7 années et 2 mois.

Assisted by: Luo Yang.

Auteur
Publications
#491224
Date format.png

I am trying to: Show date with a part in superscript

I visited this URL: hidden link

I've a custom date field. I'm using following code to show the date:
[types field='tour-start-date' style='text' format='jS F Y'][/types]

Now I wanted to show the part of the date - example(1st), (5th), (2nd), (3rd), is superscript.

Based on this doc: https://codex.wordpress.org/Function_Reference/the_modified_date#Date_with_superscript_or_subscript_number_suffixes

I updated the code from: [types field='tour-start-date' style='text' format='jS F Y'][/types] to

[types field='tour-start-date' style='text' format='j\<\s\u\p\>S\<\/\s\u\p\> F Y'][/types]
as well as
[types field='tour-start-date' style='text' format='j \<\s\u\p\>S\<\/\s\u\p\> F Y'][/types]

I expected to see:
the latter part of the date i.e. (1st), (5th), (2nd), (3rd), is superscript.

Instead, I got:

In the first case, the date does not come, instead I get the following text: 00000000p
In the second case, the date comes, and still get the following text: 00000000p

In both the cases, the desired characters do not come in second case.

#491262

This is how I do this (I needed to bold just the year):

Just wrap your date tags in superscript html tags

This should look like this:

[types field='tour-start-date' style='text' format='j'][/types]<sup>[types field='tour-start-date' style='text' format='S'][/types]</sup> [types field='tour-start-date' style='text' format='F Y'][/types]

Hope it helps.
D.

#491594

Dear shreyas,

There isn't such a feature within Types shortcode, see document:
https://toolset.com/documentation/customizing-sites-using-php/functions/#date

The valid parameter for attribute "format":
any valid WordPress date format
WordPress date and time formats:
https://codex.wordpress.org/Formatting_Date_and_Time

There isn't such an option "superscript", but you can try the workaround of D mentioned above:
https://toolset.com/forums/topic/date-in-superscript-format/#post-491262

And you can try to create your own custom shortcode for it:
https://codex.wordpress.org/Function_Reference/add_shortcode

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