Skip to content

Instantly share code, notes, and snippets.

@arelthia
Created August 6, 2015 17:03
Show Gist options
  • Select an option

  • Save arelthia/28aaa16fc6e169bb739c to your computer and use it in GitHub Desktop.

Select an option

Save arelthia/28aaa16fc6e169bb739c to your computer and use it in GitHub Desktop.
Set front page when Pod CPT is saved.
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