WordPress.org

Ready to get started?Download WordPress

Forums

T(-) Countdown
[resolved] Default expiration and Custom fields (6 posts)

  1. 3x7
    Member
    Posted 2 years ago #

    Hi,

    I have 2 questions:

    1.Can the expiration date be inserted from custom field?

    2. Is there an option for default expiration? (publish date + 1 week etc)

    thanks

    http://wordpress.org/extend/plugins/jquery-t-countdown-widget/

  2. Baden
    Member
    Plugin Author

    Posted 2 years ago #

    Yes. How good are you at working with the WordPress codex and templates?
    You would need to add some logic to your page/post template.

    For custom field, first read:
    http://codex.wordpress.org/Function_Reference/get_post_meta
    Then, from inside the post/page loop, set the time from your custom field:

    $time = get_post_meta($post->ID, 'your_custom_field_id', true);

    For publish date + time, first read:
    http://codex.wordpress.org/Function_Reference/get_the_time
    Then read: http://php.net/manual/en/function.date.php
    Then, from inside the post/page loop, set the time as a unix time stamp:

    $post_time = get_the_time('U');
    $one_week_later = $post_time + ( 7 * 24 * 60 * 60);
    $time = date('Y-m-d H:i:s', $one_week_later);

    Now that we have the the time set to the variable $time, simply call the shortcode with this value:

    echo do_shortcode('[tminus t="'.$time.'"]');

    Presto!

  3. 3x7
    Member
    Posted 2 years ago #

    Genius, it just works perfect...

    However I did manage to find a solution for inserting custom field in the shortcode, and with your code to add 7 days I managed to put it in IF statement...

    If first checks for custom field and then if there is no value it adds +7 days to the published time, here is the code if anybody is interested:

    <?php global $post; $var = get_post_meta($post->ID, '_cs-expire-date', true); $post_time = get_the_time('U');
    $one_week_later = $post_time + ( 7 * 24 * 60 * 60);
    $time = date('Y-m-d H:i:s', $one_week_later);
    if ($var == '')
    { echo do_shortcode('[tminus t="'.$time.'" omitweeks="true"/]');
     }
    else { echo do_shortcode( '[tminus t="' . $var . '" omitweeks="true"/]'); } ?>

    Thanks again!

  4. 3x7
    Member
    Posted 2 years ago #

    I would also suggest one thing...

    When it reaches the end of countdown, or if time is ZERO, to have an option to display some BIG text instead of counters "expired", or over the counters would also look nice...

    ...or just a custom text above/below the counter... to be able to change the text instead... in my case it says "expiring..." so it would be cool that if this could change to "expired" when the countdown ends...

    However great plugin! Hopefully I'll raise some funds soon and pay u a drink ;)

    Ay plans to implement the post status change or move after the countdown in the future?

    Cheers!

  5. Baden
    Member
    Plugin Author

    Posted 2 years ago #

    Please read the documentation

    Replace the counter:

    [tminus t="+5 seconds"] <h1>Some BIG text</h1> [/tminus]

    Replace text above the counter:

    [tminus t="+5 seconds" launchtarget="above"] <h1>Some BIG text</h1> [/tminus]

    Replace text below the counter:

    [tminus t="+5 seconds" launchtarget="below"] <h1>Some BIG text</h1> [/tminus]
  6. 3x7
    Member
    Posted 2 years ago #

    My bad!

    I've jumped over the first paragraph thinking at it as intro :)

    Sorry and thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.