Snippets

Martin Urbánek WP - hromadné úpravy

Created by Martin Urbánek

File hromadna-zmena-meta_value Added

  • Ignore whitespace
  • Hide word diff
+<?php
+/**
+ * Hromadná změna meta_value
+ */
+function bunch_meta_value_update($post_type = null, $posts_per_page = -1, $meta_key = null, $meta_value = null)
+{
+    $args = [];
+    $args['post_type'] = $post_type;
+    $args['posts_per_page'] = $posts_per_page;
+
+    $posts = get_posts($args);
+
+    foreach ($posts as $post) {
+
+        update_post_meta( $post->ID, $meta_key, $meta_value);
+        
+    }
+}
+bunch_meta_value_update('turnaj', -1, 'zobrazit_v_archivu', 1  );
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.