Copy Post From Main Blogsite
-
I want to be able to select a post from the posts in a specific category on my main blog/site and copy that post to the current blog/site.
I have been able to switch to the main blog, pull a list of the posts in the category, and show them in a dropdown or select box, using the code example from the get_posts function in the codex.
However, with the action set to ‘GET,’ the submit post loads the page rather than copying the post meta and content.
What can I do with the following code to load that data from setup_postdata() array and use it to update an existing post on the current blog/site?
<?php // THIS WORKS. Reactivate switch to blog and restore current blog when // action is figured out that will copy post from main blog to current blog. // switch_to_blog(1) ?> <form action="<? bloginfo('url'); ?>" method="get"> <select name="page_id" id="page_id"> <?php global $post; $args = array( 'numberposts' => -1, 'category' => 9); $posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post); ?> <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option> <?php endforeach; ?> </select> <input type="submit" name="submit" value="select" /> </form> <?php // THIS WORKS. Reactivate switch to blog and restore current blog when // action is figured out that will copy post from main blog to current blog. // restore_current_blog(); ?>
- The topic ‘Copy Post From Main Blogsite’ is closed to new replies.