Created
August 6, 2015 17:03
-
-
Save arelthia/28aaa16fc6e169bb739c to your computer and use it in GitHub Desktop.
Set front page when Pod CPT is saved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('pods_api_post_save_pod_item_book', 'tht_set_home', 10, 3); | |
| function tht_set_home( $pieces, $is_new_item, $id ) { | |
| //get the value of the 'genre' field | |
| $featured =$pieces[ 'fields' ][ 'book_featured' ][ 'value' ]; | |
| $blog = get_page_by_path( 'blog' ); | |
| if( $featured ){ | |
| update_option( 'show_on_front', 'page' ); | |
| update_option( 'page_on_front', $id ); | |
| update_option('page_for_posts', $blog->ID); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment