majick
  • Member for 6 years, 6 months
  • Last seen this week
comment

@JamesBeninger ah, good pickup! I've edited the answer to change to this.

revised

use wp_strip_all_tags instead of strip_tags

Loading…
awarded
awarded
comment

@PaoloBattiloro I updated my original functions to take either a widget ID (string) or index (number) and retested it works now. The second version I don't understand well enough to modify yet.

revised

updated code to take widget ID or index and tested

Loading…
comment

sure just swap out the line if ( $widget != $target_widget_id ) { for if ( $i != $target_widget_id ) { instead and pass the widget index (number only) to the second argument.

comment

@PaoloBattiloro yay! glad it worked out finaly. :-D can you mark the answer as correct then.

comment

@birgire love your code, looks so elegant... totally different way of thinking, for the life of me cannot understand it lol

comment

@PaoloBattiloro if you just include the var_dump calls you have within the function itself, you should be able to debug yourself if things aren't matching up.

comment

@PaoloBattiloro Try again with updated code, as it needed to match against array value of widgets instead of key.

revised

added 5 characters in body

Loading…
answered
Loading…
asked
Loading…
awarded
comment

get_the_ID() needs to be used in the loop... there is no loop in a cron job... you need to add code to get the post ID(s) you want updated some other way.

comment

What is not working, the option saving? Can you not just output the $options value to check that? Also you need to add a different priority to the second init action since it's nested inside the first, or it probably won't run.

comment

hmmm try adding is_array( $options ) && to the condition... if options have never been saved, it will not be an array yet...

comment

As Tom hinted, category is actually a taxonomy and will use the taxonomy archive template instead of the post type one... you may want to have both if you want to assign the category taxonomy to this post type like this, otherwise you might consider giving the post type it's own custom taxonomy also and a template specifically for that.

comment

@scooterlord You're welcome, it was certainly a bit of a dig to work this one out! I've added a summary solution at the top of the answer for anyone just wanting the fix.

1
2 3 4 5
62