[Resolved] Custom Fields

Home Forums Support [Resolved] Custom Fields

Home Forums Support Custom Fields

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1490149
    Jatin

    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).

    https://docs.generatepress.com/article/header-element-template-tags/#:~:text=%7B%7Bcustom_field.name%7D%7D,display%20nearly%20anything%20you%20like.&text=This%20will%20generate%20the%20full%20HTML%20for%20your%20featured%20image.

    #1490801
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #1491873
    Jatin

    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]

    #1492327
    Tom
    Lead Developer
    Lead Developer

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.