<?xml version="1.0" encoding="UTF-8"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>WordPress &#8250; Support Topic: Using WP-Cron in a theme, can it be done? I can't make it work</title>
<link>http://wordpress.org/support/</link>
<description>WordPress &#8250; Support Topic: Using WP-Cron in a theme, can it be done? I can't make it work</description>
<language>en</language>
<pubDate>Tue, 24 Nov 2009 01:38:22 +0000</pubDate>

<item>
<title>jamiefehr on "Using WP-Cron in a theme, can it be done? I can't make it work"</title>
<link>http://wordpress.org/support/topic/262707#post-1047555</link>
<pubDate>Thu, 16 Apr 2009 16:28:26 +0000</pubDate>
<dc:creator>jamiefehr</dc:creator>
<guid isPermaLink="false">1047555@http://wordpress.org/support/</guid>
<description>&#60;p&#62;As far as I can tell this should be all the code I need, but I can't make it work&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php 

		// I don&#38;#39;t want to be waiting around for things to change
		function more_cron_reccurences() {
			return array(&#38;#39;minutely&#38;#39; =&#38;gt; array(&#38;#39;interval&#38;#39; =&#38;gt; 60, &#38;#39;display&#38;#39; =&#38;gt; &#38;#39;Once Minutely&#38;#39;));
		}
		add_filter(&#38;#39;cron_schedules&#38;#39;, &#38;#39;more_cron_reccurences&#38;#39;);

		//the actual cron magic
		if (!wp_next_scheduled(&#38;#39;some_hook&#38;#39;)) {
			wp_schedule_event( time(), &#38;#39;minutely&#38;#39;, &#38;#39;some_hook&#38;#39; );
		}
//		wp_clear_scheduled_hook(&#38;#39;some_hook&#38;#39;);
		add_action(&#38;#39;some_hook&#38;#39;, &#38;#39;some_action&#38;#39;);

		function some_action(){
			$current = get_option(&#38;#39;how_long&#38;#39;);
			if (isset($current)) {
				$new = $current + 1;
				update_option(&#38;#39;how_long&#38;#39;, $new);
			} else {
				add_option(&#38;#39;how_long&#38;#39;, 0);
			}
		}

?&#38;gt;

	&#38;lt;div class=&#38;quot;notice&#38;quot;&#38;gt;
		Should change in &#38;lt;?php  echo wp_next_scheduled(&#38;#39;some_hook&#38;#39;)-time() ?&#38;gt; seconds.&#38;lt;br /&#38;gt;
		It&#38;#39;s been &#38;lt;?php echo get_option(&#38;#39;how_long&#38;#39;) ?&#38;gt; times now. &#38;lt;br /&#38;gt;
		Next scheduled for: &#38;lt;?php echo date( get_option(&#38;#39;time_format&#38;#39;), wp_next_scheduled(&#38;#39;some_hook&#38;#39;)) ?&#38;gt;
	&#38;lt;/div&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;The function updates the option correctly when fired on its own, and the timer does seem to count down, but the timer never actually fires the function.&#60;/p&#62;
&#60;p&#62;All I can think is that it's not actually possible for a cron to call a function in a theme... this would really aggravate me. Anyone have some good insight? I found the &#60;a href=&#34;http://blog.slaven.net.au/archives/2007/02/01/timing-is-everything-scheduling-in-wordpress/&#34;&#62;highly recommend post &#60;/a&#62;by Slaven. But I can't find anything on how a cron might be different when working in a template.
&#60;/p&#62;</description>
</item>

</channel>
</rss>
