Archived topic
Custom Fields
3 replies · Started by Jatin on October 15, 2020
Hi Guys,
My requirement is to generate a unique number for each post and with Prefix TPKB and display it alongside the Meta info i have on my post as shown in the screenshot. The number can start with 00001 or something and increment for each post or could be Post ID Prefixed with TPKB. (Not specially in the format shown in the pic).
Hi there,
You could build a shortcode for that:
add_shortcode( 'unique_id', function() {
return 'TPKB-' . get_the_ID();
} );
Then use [unique_id] in the Header Element.
Let me know :)
Thanks Tom This works. But can it generate numbers in sequence for example once i used it it will assign TPKB0000001 for post 1 and then so on... increment with each post and also unique. This will be easier to track the post count and then have a unique number assigned as well. If not possible, then will use the same one which you shared [already Applied]
Not without some sort of custom ID creation, as far as I know. The above will use the post ID, which is created for you.
Otherwise, you'd need to set up your own ID generation that gets applied as a custom field.