GochiSiyan

update post meta

Jul 29th, 2021
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. add_action('wp_head',function() {
  2. $cat_name = 'Gaming';
  3. $category = get_term_by('name', $cat_name, 'category');
  4. $args = array(
  5. 'post_type' => 'post',
  6. 'tax_query' => array(
  7. array(
  8. 'taxonomy' => 'category',
  9. 'field' => 'term_id',
  10. 'terms' => $category->term_id,
  11. )
  12. )
  13. );
  14. $query = new WP_Query( $args );
  15. foreach ($query->posts as $post) {
  16. update_post_meta($post->ID, 'jnews_post_split', [
  17. 'enable_post_split' => '1',
  18. 'post_split' => [
  19. [
  20. 'template' => '6',
  21. 'tag' => 'h2',
  22. 'numbering' => 'asc',
  23. 'mode' => 'normal',
  24. 'first' => '0',
  25. 'enable_toc' => '1',
  26. 'toc_type' => 'both',
  27. ],
  28. ],
  29. ]);
  30. }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment