</span>
<span class="st_h"></select></pre></span>
<span class="st_h"><pre>function subpost_template($content) {</span>
<span class="st_h"> if(is_singular()) {</span>
<span class="st_h"> remove_filter('</span>posts_where<span class="st_h">','</span>where_no_parent<span class="st_h">');</span>
<span class="st_h"> }</span>
<span class="st_h"> $parentID = get_the_ID();</span>
<span class="st_h"> $childposts = get_posts(array(</span>
<span class="st_h"> '</span>post_type<span class="st_h">' => '</span>post<span class="st_h">',</span>
<span class="st_h"> '</span>numberposts<span class="st_h">' => -1,</span>
<span class="st_h"> '</span>post_status<span class="st_h">' => '</span>publish<span class="st_h">',</span>
<span class="st_h"> '</span>post_parent<span class="st_h">' => $parentID</span>
<span class="st_h"> ));</span>
<span class="st_h"> $subcontent = "";</span>
<span class="st_h"> foreach($childposts as $childpost){</span>
<span class="st_h"> $subcontent .= "</pre></span>
<span class="st_h"><blockquote>"; $subcontent .= "</span>
<span class="st_h"><h3>".$childpost->post_title."</h3></span>
<span class="st_h">"; $subcontent .= $childpost->post_content; $subcontent .= '</span> <span class="sy0"><</span>a href<span class="sy0">=</span><span class="st0">"'.get_edit_post_link(<span class="es4">$childpost->ID</span>).'"</span> rel<span class="sy0">=</span><span class="st0">"nofollow"</span><span class="sy0">></span>Edit<span class="sy0"></</span>a<span class="sy0">></span> <span class="st_h">'; $subcontent .= "</blockquote></span>
<span class="st_h"><pre></span>
<span class="st_h">";</span>
<span class="st_h"> }</span>
<span class="st_h"> $content .= $subcontent;</span>
<span class="st_h"> return $content;</span>
<span class="st_h">}</span></pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="bwp-syntax-source">
<pre class="no-parse">< ?php
/*
Plugin Name: WP Sub Post
Plugin URI: http://wordpress.org/#
Description: You can make a post is a child of another post.
Author: Takien
Version: 0.1 Alpha
Author URI: /
*/
////////////////////////////
class Walker_PostDropdown extends Walker {
var $tree_type = 'post';
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID');
function start_el(&$output, $page, $depth, $args) {
$pad = str_repeat(' ', $depth * 3);
$output .= "\tID\"";
if ( $page->ID == $args['selected'] )
$output .= ' selected="selected"';
$output .= '>';
$title = esc_html($page->post_title);
$output .= "$pad$title";
$output .= "\n";
}
}
/////////////
function &wp_get_posts($args = '') {
global $wpdb;
$defaults = array(
'child_of' => 0, 'sort_order' => 'ASC',
'sort_column' => 'post_title', 'hierarchical' => 1,
'exclude' => '', 'include' => '',
'meta_key' => '', 'meta_value' => '',
'authors' => '', 'parent' => -1, 'exclude_tree' => '',
'number' => '', 'offset' => 0
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$number = (int) $number;
$offset = (int) $offset;
$cache = array();
$key = md5( serialize( compact(array_keys($defaults)) ) );
if ( $cache = wp_cache_get( 'wp_get_posts', 'posts' ) ) {
if ( is_array($cache) && isset( $cache[ $key ] ) ) {
$pages = apply_filters('wp_get_posts', $cache[ $key ], $r );
return $pages;
}
}
if ( !is_array($cache) )
$cache = array();
$inclusions = '';
if ( !empty($include) ) {
$child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include
$parent = -1;
$exclude = '';
$meta_key = '';
$meta_value = '';
$hierarchical = false;
$incpages = preg_split('/[\s,]+/',$include);
if ( count($incpages) ) {
foreach ( $incpages as $incpage ) {
if (empty($inclusions))
$inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage);
else
$inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage);
}
}
}
if (!empty($inclusions))
$inclusions .= ')';
$exclusions = '';
if ( !empty($exclude) ) {
$expages = preg_split('/[\s,]+/',$exclude);
if ( count($expages) ) {
foreach ( $expages as $expage ) {
if (empty($exclusions))
$exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage);
else
$exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage);
}
}
}
if (!empty($exclusions))
$exclusions .= ')';
$author_query = '';
if (!empty($authors)) {
$post_authors = preg_split('/[\s,]+/',$authors);
if ( count($post_authors) ) {
foreach ( $post_authors as $post_author ) {
//Do we have an author id or an author login?
if ( 0 == intval($post_author) ) {
$post_author = get_userdatabylogin($post_author);
if ( empty($post_author) )
continue;
if ( empty($post_author->ID) )
continue;
$post_author = $post_author->ID;
}
if ( '' == $author_query )
$author_query = $wpdb->prepare(' post_author = %d ', $post_author);
else
$author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author);
}
if ( '' != $author_query )
$author_query = " AND ($author_query)";
}
}
$join = '';
$where = "$exclusions $inclusions ";
if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
// meta_key and meta_value might be slashed
$meta_key = stripslashes($meta_key);
$meta_value = stripslashes($meta_value);
if ( ! empty( $meta_key ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
if ( ! empty( $meta_value ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value);
}
if ( $parent >= 0 )
$where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
$query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'post' AND post_status = 'publish') $where ";
$query .= $author_query;
$query .= " ORDER BY " . $sort_column . " " . $sort_order ;
if ( !empty($number) )
$query .= ' LIMIT ' . $offset . ',' . $number;
$pages = $wpdb->get_results($query);
if ( empty($pages) ) {
$pages = apply_filters('wp_get_posts', array(), $r);
return $pages;
}
// Sanitize before caching so it'll only get done once
$num_pages = count($pages);
for ($i = 0; $i < $num_pages; $i++) {
$pages[$i] = sanitize_post($pages[$i], 'raw');
}
// Update cache.
update_page_cache($pages);
if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of, $pages);
if ( !empty($exclude_tree) ) {
$exclude = (int) $exclude_tree;
$children = get_page_children($exclude, $pages);
$excludes = array();
foreach ( $children as $child )
$excludes[] = $child->ID;
$excludes[] = $exclude;
$num_pages = count($pages);
for ( $i = 0; $i < $num_pages; $i++ ) {
if ( in_array($pages[$i]->ID, $excludes) )
unset($pages[$i]);
}
}
$cache[ $key ] = $pages;
wp_cache_set( 'wp_get_posts', $cache, 'posts' );
$pages = apply_filters('wp_get_posts', $pages, $r);
return $pages;
}
//////////////
function walk_post_dropdown_tree() {
$args = func_get_args();
if ( empty($args[2]['walker']) ) // the user's options are the third parameter
$walker = new Walker_PostDropdown;
else
$walker = $args[2]['walker'];
return call_user_func_array(array(&$walker, 'walk'), $args);
}
function wp_dropdown_posts($args = '') {
$defaults = array(
'depth' => 0, 'child_of' => 0,
'selected' => 0, 'echo' => 1,
'name' => 'page_id', 'show_option_none' => '', 'show_option_no_change' => '',
'option_none_value' => ''
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$pages = wp_get_posts($r);
$output = '';
$name = esc_attr($name);
if ( ! empty($pages) ) {
$output = "<select name="\"$name\"">
<option value="\"-1\"">$show_option_no_change</option>
<option value="\""">$show_option_none</option>\n";
</select>
<select name="\"$name\"">}
</select>
$output = apply_filters('wp_dropdown_pages', $output);
if ( $echo )
echo $output;
return $output;
}
/////////////////////////////
/* Use the admin_menu action to define the custom boxes */
add_action('admin_menu', 'myplugin_add_custom_box');
/* Use the save_post action to do something with the data entered */
add_action('save_post', 'myplugin_save_postdata');
/* Adds a custom section to the "advanced" Post and Page edit screens */
function myplugin_add_custom_box() {
if( function_exists( 'add_meta_box' )) {
add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post', 'side','high' );
//add_meta_box( $id, $title, $callback, $page, $context, $priority );
add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page', 'advanced' );
} else {
add_action('dbx_post_advanced', 'myplugin_old_custom_box' );
add_action('dbx_page_advanced', 'myplugin_old_custom_box' );
}
}
function myplugin_inner_custom_box() {
echo '
<pre><select name="\"$name\"">'; echo '
</select><input id="myplugin_noncename" name="myplugin_noncename" type="hidden" value="' .
wp_create_nonce( plugin_basename(__FILE__) ) . '" /><select name="\"$name\"">'; ?>
</select></pre>
<h5><?php _e('Parent') ?></h5>
<pre><label for="post_parent">Please select the parent of this post</label><select name="\"$name\""> <?php $currentid = $_GET['post']; wp_dropdown_posts(array('exclude_tree' => $currentid, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Post (no parent)'), 'sort_column' => 'menu_order, post_title')); } /* Prints the edit form for pre-WordPress 2.5 post/page */ function myplugin_old_custom_box() { echo '
</select></pre>
<div class="dbx-b-ox-wrapper">' . "\n"; echo '
<fieldset id="myplugin_fieldsetid" class="dbx-box">' . "\n"; echo '
<div class="dbx-h-andle-wrapper">
<h3 class="dbx-handle">' . __( 'WP Sub Posts', 'myplugin_textdomain' ) . "</h3>
</div>
"; echo '
<div class="dbx-c-ontent-wrapper">
<div class="dbx-content">'; // output editing form myplugin_inner_custom_box(); // end wrapper echo "</div>
</div></fieldset>
</div>
<pre><select name="\"$name\"">\n"; } /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want // to do anything if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; // Check permissions if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } // OK, we're authenticated: we need to find and save the data $mydata = $_POST['parent_id']; return $mydata; } add_filter('posts_where','where_no_parent'); add_filter ('the_content','subpost_template', 1, 2 ); function subpost_template($content) { if(is_singular) { remove_filter('posts_where','where_no_parent'); } echo $content; $idnya = get_the_ID(); $child = new WP_Query("post_type=post&post_parent=".$idnya.""); while($child->have_posts()) : $child->the_post(); echo '
</select></pre>
<blockquote>'; echo '
<h3>'; the_title(); echo '</h3>
'; $childid = get_the_ID(); the_content(); edit_post_link('Edit','','',$childid); echo '</blockquote>
<pre><select name="\"$name\"">'; endwhile; wp_reset_query(); } function where_no_parent($where) { global $wpdb; $where .= " AND post_parent = 0"; return $where; } ?>
</select></pre>
<pre>function subpost_template($content) {
if(is_singular()) {
remove_filter(‘posts_where’,‘where_no_parent’);
}
$parentID = get_the_ID();
$childposts = get_posts(array(
‘post_type’ => ‘post’,
‘numberposts’ => -1,
‘post_status’ => ‘publish’,
‘post_parent’ => $parentID
));
$subcontent = “”;
foreach($childposts as $childpost){
$subcontent .= “</pre>
<blockquote>”; $subcontent .= ”
<h3>“.$childpost->post_title.”</h3>
“; $subcontent .= $childpost->post_content; $subcontent .= ‘ <a href=”’.get_edit_post_link($childpost->ID).‘“ rel=“nofollow”>Edit</a> ’; $subcontent .= “</blockquote>
<pre>
”;
}
$content .= $subcontent;
return $content;
}</pre>
</div>
</div>
[php title=“wp_dropdown_posts()” block=“WP Dropdown Post”]</p>
<pre>global $post;
$currentid = $_GET[‘post’];
wp_dropdown_posts(array(‘exclude_tree’ => $currentid,
‘selected’ => $post->post_parent,
‘name’ => ‘parent_id’,
‘show_option_none’ => __(‘Main Post (no parent)’),
‘sort_column’ => ‘menu_order, post_title’));</pre>
<p>
WP Sub Post is a wordpress plugin that allow you to make your wordpress post has a parent or child post.
Notes:
- Child post is a real post that has a parent.
- Child post only displayed on it’s parent post page or when parent page is displayed.
- Child post can not be viewed individually.
- Child post has all possibility like a normal post, such as attachment, custom fields etc.
Features:
- Add/edit parent post directly from your post area.
- No need to edit theme file.
Limitations:
- No setting page
- I don’t know about it’s compatibility.
Bugs:
- Not compatible with my syntax highlight plugin 😀
[block title=”Screenshot”]
Plugin page:
New/Edit post page:
View Single Post:
RSS:
[/block]
Code:
Here is the code of this plugins… Hahaha.. little bit messy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
< ?php /* Plugin Name: WP Sub Post Plugin URI: http://wordpress.org/# Description: You can make a post is a child of another post. Author: Takien Version: 0.1 Alpha Author URI: / */ //////////////////////////// class Walker_PostDropdown extends Walker { var $tree_type = 'post'; var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); function start_el(&$output, $page, $depth, $args) { $pad = str_repeat(' ', $depth * 3); $output .= "\tID\""; if ( $page->ID == $args['selected'] ) $output .= ' selected="selected"'; $output .= '>'; $title = esc_html($page->post_title); $output .= "$pad$title"; $output .= "\n"; } } ///////////// function &wp_get_posts($args = '') { global $wpdb; $defaults = array( 'child_of' => 0, 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0 ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $number = (int) $number; $offset = (int) $offset; $cache = array(); $key = md5( serialize( compact(array_keys($defaults)) ) ); if ( $cache = wp_cache_get( 'wp_get_posts', 'posts' ) ) { if ( is_array($cache) && isset( $cache[ $key ] ) ) { $pages = apply_filters('wp_get_posts', $cache[ $key ], $r ); return $pages; } } if ( !is_array($cache) ) $cache = array(); $inclusions = ''; if ( !empty($include) ) { $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include $parent = -1; $exclude = ''; $meta_key = ''; $meta_value = ''; $hierarchical = false; $incpages = preg_split('/[\s,]+/',$include); if ( count($incpages) ) { foreach ( $incpages as $incpage ) { if (empty($inclusions)) $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage); else $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage); } } } if (!empty($inclusions)) $inclusions .= ')'; $exclusions = ''; if ( !empty($exclude) ) { $expages = preg_split('/[\s,]+/',$exclude); if ( count($expages) ) { foreach ( $expages as $expage ) { if (empty($exclusions)) $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage); else $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage); } } } if (!empty($exclusions)) $exclusions .= ')'; $author_query = ''; if (!empty($authors)) { $post_authors = preg_split('/[\s,]+/',$authors); if ( count($post_authors) ) { foreach ( $post_authors as $post_author ) { //Do we have an author id or an author login? if ( 0 == intval($post_author) ) { $post_author = get_userdatabylogin($post_author); if ( empty($post_author) ) continue; if ( empty($post_author->ID) ) continue; $post_author = $post_author->ID; } if ( '' == $author_query ) $author_query = $wpdb->prepare(' post_author = %d ', $post_author); else $author_query .= $wpdb->prepare(' OR post_author = %d ', $post_author); } if ( '' != $author_query ) $author_query = " AND ($author_query)"; } } $join = ''; $where = "$exclusions $inclusions "; if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) { $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; // meta_key and meta_value might be slashed $meta_key = stripslashes($meta_key); $meta_value = stripslashes($meta_value); if ( ! empty( $meta_key ) ) $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key); if ( ! empty( $meta_value ) ) $where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_value = %s", $meta_value); } if ( $parent >= 0 ) $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); $query = "SELECT * FROM $wpdb->posts $join WHERE (post_type = 'post' AND post_status = 'publish') $where "; $query .= $author_query; $query .= " ORDER BY " . $sort_column . " " . $sort_order ; if ( !empty($number) ) $query .= ' LIMIT ' . $offset . ',' . $number; $pages = $wpdb->get_results($query); if ( empty($pages) ) { $pages = apply_filters('wp_get_posts', array(), $r); return $pages; } // Sanitize before caching so it'll only get done once $num_pages = count($pages); for ($i = 0; $i < $num_pages; $i++) { $pages[$i] = sanitize_post($pages[$i], 'raw'); } // Update cache. update_page_cache($pages); if ( $child_of || $hierarchical ) $pages = & get_page_children($child_of, $pages); if ( !empty($exclude_tree) ) { $exclude = (int) $exclude_tree; $children = get_page_children($exclude, $pages); $excludes = array(); foreach ( $children as $child ) $excludes[] = $child->ID; $excludes[] = $exclude; $num_pages = count($pages); for ( $i = 0; $i < $num_pages; $i++ ) { if ( in_array($pages[$i]->ID, $excludes) ) unset($pages[$i]); } } $cache[ $key ] = $pages; wp_cache_set( 'wp_get_posts', $cache, 'posts' ); $pages = apply_filters('wp_get_posts', $pages, $r); return $pages; } ////////////// function walk_post_dropdown_tree() { $args = func_get_args(); if ( empty($args[2]['walker']) ) // the user's options are the third parameter $walker = new Walker_PostDropdown; else $walker = $args[2]['walker']; return call_user_func_array(array(&$walker, 'walk'), $args); } function wp_dropdown_posts($args = '') { $defaults = array( 'depth' => 0, 'child_of' => 0, 'selected' => 0, 'echo' => 1, 'name' => 'page_id', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $pages = wp_get_posts($r); $output = ''; $name = esc_attr($name); if ( ! empty($pages) ) { $output = "<select name="\"$name\""> <option value="\"-1\"">$show_option_no_change</option> <option value="\""">$show_option_none</option>\n"; </select> <select name="\"$name\"">} </select> $output = apply_filters('wp_dropdown_pages', $output); if ( $echo ) echo $output; return $output; } ///////////////////////////// /* Use the admin_menu action to define the custom boxes */ add_action('admin_menu', 'myplugin_add_custom_box'); /* Use the save_post action to do something with the data entered */ add_action('save_post', 'myplugin_save_postdata'); /* Adds a custom section to the "advanced" Post and Page edit screens */ function myplugin_add_custom_box() { if( function_exists( 'add_meta_box' )) { add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post', 'side','high' ); //add_meta_box( $id, $title, $callback, $page, $context, $priority ); add_meta_box( 'myplugin_sectionid', __( 'WP Sub Posts', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page', 'advanced' ); } else { add_action('dbx_post_advanced', 'myplugin_old_custom_box' ); add_action('dbx_page_advanced', 'myplugin_old_custom_box' ); } } function myplugin_inner_custom_box() { echo ' <pre><select name="\"$name\"">'; echo ' </select><input id="myplugin_noncename" name="myplugin_noncename" type="hidden" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" /><select name="\"$name\"">'; ?> </select></pre> <h5><?php _e('Parent') ?></h5> <pre><label for="post_parent">Please select the parent of this post</label><select name="\"$name\""> <?php $currentid = $_GET['post']; wp_dropdown_posts(array('exclude_tree' => $currentid, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('Main Post (no parent)'), 'sort_column' => 'menu_order, post_title')); } /* Prints the edit form for pre-WordPress 2.5 post/page */ function myplugin_old_custom_box() { echo ' </select></pre> <div class="dbx-b-ox-wrapper">' . "\n"; echo ' <fieldset id="myplugin_fieldsetid" class="dbx-box">' . "\n"; echo ' <div class="dbx-h-andle-wrapper"> <h3 class="dbx-handle">' . __( 'WP Sub Posts', 'myplugin_textdomain' ) . "</h3> </div> "; echo ' <div class="dbx-c-ontent-wrapper"> <div class="dbx-content">'; // output editing form myplugin_inner_custom_box(); // end wrapper echo "</div> </div></fieldset> </div> <pre><select name="\"$name\"">\n"; } /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want // to do anything if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; // Check permissions if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } // OK, we're authenticated: we need to find and save the data $mydata = $_POST['parent_id']; return $mydata; } add_filter('posts_where','where_no_parent'); add_filter ('the_content','subpost_template', 1, 2 ); function subpost_template($content) { if(is_singular) { remove_filter('posts_where','where_no_parent'); } echo $content; $idnya = get_the_ID(); $child = new WP_Query("post_type=post&post_parent=".$idnya.""); while($child->have_posts()) : $child->the_post(); echo ' </select></pre> <blockquote>'; echo ' <h3>'; the_title(); echo '</h3> '; $childid = get_the_ID(); the_content(); edit_post_link('Edit','','',$childid); echo '</blockquote> <pre><select name="\"$name\"">'; endwhile; wp_reset_query(); } function where_no_parent($where) { global $wpdb; $where .= " AND post_parent = 0"; return $where; } ?> [/php] </select><strong> Revision by <a href="http://www.kaskus.us/member.php?u=1202930">polvocdo</a></strong><select id="\"$name\"" name="\"$name\""> 1 </select><strong> Revision by <a href="http://www.kaskus.us/member.php?u=1202930">polvocdo</a></strong><select id="\"$name\"" name="\"$name\""> 1 |