Advertisement
arie_cristianD

auto add jnews_primary_category in classic editor

Oct 21st, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. global $pagenow;
  2. if ( $pagenow === 'post.php' || $pagenow === 'post-new.php' ) {
  3.     add_action( 'save_post', 'add_jnews_primary_category', 99 );
  4.     add_action( 'edit_post', 'add_jnews_primary_category', 99 );
  5. }
  6.  
  7. function add_jnews_primary_category( $post_id ) {
  8.     $cat_id = 5; /* change this  */
  9.     update_post_meta( $post_id, 'jnews_primary_category', array( 'id' => (int) $cat_id ) );
  10. }
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement