Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Set default valut for Custom Primary Category Fields.
- */
- function set_default_primary_category( $value, $post_id, $field ) {
- if ( empty( $value ) ) {
- $jnews_primary_category = get_post_meta( $post_id, 'jnews_primary_category', true );
- if ( is_array( $jnews_primary_category ) && isset( $jnews_primary_category['id'] ) ) {
- $value = $jnews_primary_category['id'];
- }
- }
- return $value;
- }
- /**
- * Set default valut for Custom Hide Category Fields.
- */
- function set_default_hide_category( $value, $post_id, $field ) {
- if ( empty( $value ) ) {
- $jnews_primary_category = get_post_meta( $post_id, 'jnews_primary_category', true );
- if ( is_array( $jnews_primary_category ) && isset( $jnews_primary_category['hide'] ) ) {
- $value = explode( ',', $jnews_primary_category['hide'] );
- }
- }
- return $value;
- }
- add_filter( 'acf/load_value/name=custom_primary_category', 'set_default_primary_category', 10, 3 );
- add_filter( 'acf/load_value/name=custom_hide_category', 'set_default_hide_category', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement