• OK. Our site is only updated once a week (on mondays when the new issue of the paper comes out). We add all the articles over the weekend before and set the timestamps for each story to go live at 0:01 on the monday morning.

    Instead of doing this for *every* story I’d like to be able to go to the write post options page and to set a timestamp there and this will automatically set for all new posts.. (so instead of it querying the current time when it loads the write posts screen it will query the set timestamp time and use that)

    That way I can edit the timestamp once a week and save lots and lots of work.

    This will also have the advantage of not needing the sub-eds as level 5 users as they currently are for editting the timestamp, but should really be level 3..

    So how would I go about doing such a thing? I’d ideally like this feature as a plugin but hacking would do too. I’m happy to work on it myself but need a lot of guidance! Or a nice bored person is welcome to have a go themselves ??

    Thanks!!

Viewing 12 replies - 1 through 12 (of 12 total)
  • This appears to be working for me, but it is a quick hack…

    Edit wp-admin/admin-functions.php, we’re going to put a new function in there…



    function get_next_week($tint) {
    $weekdayid = date("w", $tint);
    $startoftoday=mktime(0,1,0,date("n", $tint), date("j", $tint), date("Y", $tint));
    return $startoftoday + ((8 - $weekdayid) * 86400);
    }

    Now, Find the line that says:



    $time_adj = time() + (get_settings('gmt_offset') * 3600);

    It should be in a function called ‘touch_time’, comment the line above out (put // infront of it and add a line so that it looks like:



    //$time_adj = time() + (get_settings('gmt_offset') * 3600);
    $time_adj = get_next_week(time());

    This will cause all posts to default to 00:01 on the following monday.

    Thread Starter lellie

    (@lellie)

    ooo that sounds great.. it’s obviously not portable for other users who want to set timestamps.. but it’s ideal for me. That means I don’t even have to update it.. which is nice.. ??

    I shall give it a go when I’ve updated all these new stories.. It certainly sounds like it will work. Will let you know if it’s successful later. ??

    a quick hack will do for now anyway.. if I get braver with plugins I might do it properly! heh.

    I’ll have a think about doing it properly too… ??

    Thread Starter lellie

    (@lellie)

    Thanks a lot though, I really appreciate the help.

    It’s weird I asked a load of questions back in August, this included and no one really responded.. This week I’ve asked a couple things again and had solutions found in minutes! Things are great in WordPress world at the moment. Lots of exciting developments..

    Thread Starter lellie

    (@lellie)

    Ok.. implemented the hack but I think there might be a problem with server time or something – it’s currently saying feb 13th – when it should be feb 6th.. Any ideas?

    Thread Starter lellie

    (@lellie)

    Ok.. making it

    return $startoftoday + ((1 - $weekdayid) * 86400);

    seems to have worked..

    but will that fix it properly if you say 8 – works?

    Thread Starter lellie

    (@lellie)

    OK, although this is much better..

    I’ve changed it so that “edit timestamp” is ticked automatically on the write post screen because if it’s not it automatically resets the timestamp to the correct time when the post is published/saved..

    This means I still have to have advanced controls showing the add timestamp option and I still have to have users set to level 5 plus.. It would be nice if I didn’t..

    However this is still much much better. It’s so quick now I don’t have to enter the timestamp for every post. Just wish users could be lower than level 5 and I didn’t have to show the timestamp options anymore..

    So there’s room for improvement but for now as a quick fix this is very handy indeed.

    jaredquinn

    (@jaredquinn)

    Ok i’ve developed this alot further..

    You can find the details at https://jaredquinn.info/it-related/software/2006.02.07/set-post-date-plugin-released/

    Thread Starter lellie

    (@lellie)

    oo thanks! I have wordpress 1.5 on the site I’m using it with (I’m scared to upgrade due to various crazy template issues I’m expecting) I shall try it though and see if it works. ??

    ryebrye

    (@ryebrye)

    I updated and didn’t have ANY template issues. WordPress 2.0 didn’t change anything related to the them… If you are really worried, I would suggest making a complete backup of your DB on your local computer, (install Apache, MySQL, and PHP) – and then run the test offsite first – then try it on your live one.

    Cool feature with the timestamp adjusting. I’ll have to try that one out.

    Thread Starter lellie

    (@lellie)

    yeah I’m meant to be installing a backup elsewhere on the dev site as I need to do a lot of work on the site anyway.. but just don’t have the time.

    Thread Starter lellie

    (@lellie)

    since installing the new plugin for this I find the database has problems publishing posts – it seems to take many times to get a post to publish.. I don’t know if this is causing an unneccessary load on the server maybe?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Timestamps – preset them in write post options?’ is closed to new replies.