• Resolved pvashist75

    (@pvashist75)


    Hi i am using types plugin to create a date field. On the front end i want to show the date through custom query using get_posts. I tried fetching field data through get_post_meta which is giving some number string. I checked the mysql it is the same saved there. So i tried using types_render_field but can’t find any documentation on how to pass the post id for which i want the date field. Can you please share the method to get custom date field in custom loop. Other fields are working fine.

    https://www.ads-software.com/plugins/types/

Viewing 2 replies - 1 through 2 (of 2 total)
  • It is a timestamp, to display it you can use:

    <?php
    $timestamp = get_post_meta( $post->ID, 'wpcf-date', true );
    echo date_i18n( get_option( 'date_format' ), $timestamp );
    ?>

    https://codex.www.ads-software.com/Function_Reference/date_i18n

    If you prefer to use types_render_field(), there is a post_id argument:

    <?php
    echo types_render_field( 'date', array( 'post_id' => $post->ID ) );
    ?>

    Note that if you don’t supply the post_id argument, it should pick up the current post id from the loop.

    Thread Starter pvashist75

    (@pvashist75)

    Great get post meta worked. May i am doing something wrong with types render field.

    Thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with date field’ is closed to new replies.