-
-
Save simonkberg/264722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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