Skip to content

Instantly share code, notes, and snippets.

@simonkberg
Forked from hunk/gist:244722
Created December 28, 2009 15:23
Show Gist options
  • Save simonkberg/264722 to your computer and use it in GitHub Desktop.
Save simonkberg/264722 to your computer and use it in GitHub Desktop.
<?php
/* Place in /wp-content/ */
include('../wp-config.php');
include('../wp-load.php');
global $wpdb;
//Settings
$type = 0; //1 for post, everything else for pages
$category_id = 1; // ID of the category, or...
$parent_id = 2; // ID of the page
$write_panel_id = 3; // ID of the Write Panel
if ($type == 1) { //For posts
$add = new WP_Query('cat='.$category_id);
if ($add->have_posts()) {
while ($add->have_posts()) {
$add->the_post();
update_post_meta($post->ID, "_mf_write_panel_id", $write_panel_id);
echo $post->post_title.'<br/>';
}
}
} else { //For pages and their children
$qry = "SELECT ID, post_title, post_parent FROM " . $wpdb->posts .
" WHERE post_parent='" . $parent_id . "'";
$posts = $wpdb->get_results( $qry );
foreach( $posts as $post ) {
update_post_meta($post->ID, "_mf_write_panel_id", $write_panel_id);
echo $post->post_title.'<br/>';
}
}
/* Live long and prosper */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment