Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter diekunstderfuge

    (@diekunstderfuge)

    I wonder too about the serialization, so I tried to re-serialize the data by doing something like:

    $global wpdb;
    $data = $wpdb->get_var('SELECT option_value FROM wp_options WHERE option_name = \'gcb_#\'');
    $updated = update_option('gcb_#', serialize($data));
    
    // Verify.
    ($updated) ? echo 'Updated!' : echo 'Not updated!';

    GCB class has a method which is just a wrapper for the same update_option() call.

    Here are the string data values for two of the content blocks that stopped being recognized by GCB after the phpMyAdmin action I described in the original post. The first is from “before” the update (I had to grab the values from the copy of the db on my testing server), and the second is from after the update triggered by phpMyAdmin.

    Array
    (
        [0] => Array
            (
                [option_name] => gcb_1
                [option_value] => s:400:"a:6:{s:4:"name";s:14:"Mailchimp Form";s:11:"description";s:85:"Basic Mailchimp signup form with only required fields (first name, last name, email).";s:5:"value";s:150:"<aside id=\"mailing-list-block\" class=\"large-4 columns\"><h4>Stay Connected</h4>[mc4wp_form]</aside>
    
    ";s:9:"custom_id";s:18:"mailing_list_block";s:4:"type";s:5:"other";s:2:"id";i:1;}";
            )
    
        [1] => Array
            (
                [option_name] => gcb_3
                [option_value] => s:384:"a:6:{s:4:"name";s:11:"Other Block";s:11:"description";s:0:"";s:5:"value";s:230:"<aside id=\"other-block\" class=\"large-4 columns\">
    <h4>Some Other Block</h4>
    [contentblock id=newsfeed]
    [contentblock id=donation_block]
    [contentblock id=socialfeedblock]
    </aside>";s:9:"custom_id";s:11:"other_block";s:4:"type";s:5:"other";s:2:"id";i:3;}";
            )

    After:

    Array
    (
        [0] => Array
            (
                [option_name] => gcb_1
                [option_value] => s:400:"a:6:{s:4:"name";s:14:"Mailchimp Form";s:11:"description";s:85:"Basic Mailchimp signup form with only required fields (first name, last name, email).";s:5:"value";s:150:"<aside id=\"mailing-list-block\" class=\"large-4 columns\"><h4>Stay Connected</h4>[mc4wp_form]</aside>
    
    ";s:9:"custom_id";s:18:"mailing_list_block";s:4:"type";s:5:"other";s:2:"id";i:1;}";
            )
    
        [1] => Array
            (
                [option_name] => gcb_3
                [option_value] => s:384:"a:6:{s:4:"name";s:11:"Other Block";s:11:"description";s:0:"";s:5:"value";s:230:"<aside id=\"other-block\" class=\"large-4 columns\">
    <h4>Some Other Block</h4>
    [contentblock id=newsfeed]
    [contentblock id=donation_block]
    [contentblock id=socialfeedblock]
    </aside>";s:9:"custom_id";s:11:"other_block";s:4:"type";s:5:"other";s:2:"id";i:3;}";
            )

    At this point I’m considering uninstalling GCB from my local environment, then reinstalling and importing the “clean” version of the content blocks that I exported from my testing server. Any other thoughts though are greatly appreciated!

    Thread Starter diekunstderfuge

    (@diekunstderfuge)

    Yes, that works, and thank you for pointing out that disclaimer in the codex; I immediately saw that ACF was storing my dates as YYYYMMDD instead of YYYY-MM-DD and I probably would have spent much longer hunting for the source of the problem.

    Thanks again for your help!

    Cheers!

    Thread Starter diekunstderfuge

    (@diekunstderfuge)

    Hi Jonathan,

    Thanks for your reply! Your code certainly works, but I’m a little unclear on where in the filter/callback to specify that it is a specific ACF field, i.e., meta_keyname, to which the callback should apply. In other words, how do I make sure it is the value of my custom field that falls between $before and $after, and not another WP date field, like post creation date or publish date? Do I need to do something with the $filter argument? Forgive me, I’m still getting used to WP development!

    Thanks again!

    I would also like to know how to do this! I would like to have a query return only 1 post, the post with an ACF date field where that date is closest to the current date.

Viewing 4 replies - 1 through 4 (of 4 total)