Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init' , 'update_show_page_layout_setting' );
- function update_show_page_layout_setting() {
- $pageids_to_check = array(
- 3235, // add your pageid here, optionally add more pageids that also have these fields connected
- );
- foreach ( $pageids_to_check as $id ):
- // if layout is already set to layout2, we can also return early
- if ( get_field( 'show_this_layout' , $id ) == 'layout2' ) return;
- // check if current time is later than the set ACF field-value
- // if it is, we update the show_this_layout field to display the alternate layout
- // also check if auto_switch_layout_date is actually set
- //
- if ( get_field( 'auto_switch_layout_date' , $id ) && date( 'Ymd H:i:s' ) >= get_field( 'auto_switch_layout_date' , $id ) ) update_post_meta( $id , 'show_this_layout' , 'layout2' );
- endforeach;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement