Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can pass a variable to your <a href="http://codex.wordpress.org/Function_Reference/add_action" rel="nofollow">add_action()</a>:</p> <pre><code>add_action( $tag, $function_to_add, $arg ); </code></pre> <p>But you can also use <a href="http://codex.wordpress.org/Function_Reference/do_action" rel="nofollow">do_action()</a> instead of adding action every time your cron runs:</p> <pre><code>do_action( $tag, $arg ) </code></pre> <p>Anyway, is good to store your <code>$offset</code> somewhere, so I see two options:</p> <p>Store your persistent values in <a href="http://codex.wordpress.org/Class_Reference/WP_Object_Cache" rel="nofollow">WP_Object_Cache</a>. Maybe reading this documentation, you can find another elegant solution for your performance with large query results.</p> <p>Recording in the database your actual <code>$offset</code> value using <a href="http://codex.wordpress.org/Function_Reference/add_option" rel="nofollow">add_option()</a> and <a href="http://codex.wordpress.org/Function_Reference/get_option" rel="nofollow">get_option()</a>.</p> <p>If you store <code>your $offset</code> variable, your rock_and_roll function don't need to receive a parameter anymore, you just need to retrieve it inside the function.</p> <pre><code>function rock_n_roll() { // Retrieve $offset value from WP_Object_Cache // or from database with get_option() query_posts(array( 'post_type' =&gt; 'wine', 'order' =&gt; 'ASC', 'posts_per_page' =&gt; -1, 'offset' =&gt; $offset )); while (have_posts()) : the_post(); //compare values against scraped results //write results to DB with update_post_meta endwhile; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload