• how to Create a post when a post viewed?
    i tried alot of query but failed
    here is my code:

    <?php
    	$relation=the_title('','',false);
    	$args = array(
    		'post_type' => 'online_manga',
    		'post_parent' => null, // any parent
    		'meta_key' => 'ParentID',
    		'meta_value' => $post->ID,
    		'post_status' => array('draft','publish'),
    		'orderby' => 'title');
    	$yell = null;
    	$yell = new WP_Query($args);
    	while ($yell->have_posts()) : $yell->the_post();
    		$omtitle=the_title('','',false);
    		if ($omtitle != $relation){
        			$my_post = array();
    				$my_post['post_author'] = 1;
    				$my_post['post_title'] = the_title('','',false);
    				$my_post['comment_status'] = 'open';
    				$my_post['ping_status'] = 'closed';
    				$my_post['post_type'] = 'online_manga';
    				$my_post['post_status'] = 'draft';
    				$myonlinepostid=wp_insert_post( $my_post );
    				update_post_meta ($myonlinepostid, 'ParentID', $post->ID);
    		}
    	endwhile;
    	wp_reset_query();
    	?>

    really need help here. thanks

  • The topic ‘how to Create a post when a post viewed’ is closed to new replies.