Viewing 2 replies - 1 through 2 (of 2 total)
  • Do you mean you want to create posts from a static page?
    If so, you can do that by creating a custom page template (https://codex.www.ads-software.com/Pages#Creating_Your_Own_Page_Templates) with the following code:

    <?php
    /*
    Template Name: Submit Post Form
    */
    ?>
    
    <?php get_header(); ?>
    <div id="main">
    <div id="content" class="narrowcolumn">
    
    <div class="post">
    <h2><?php single_post_title(); ?></h2>
    
    <?php if ( !current_user_can('edit_posts') ) : ?>
    
    To submit posts, first <?php wp_loginout(); ?> or <?php wp_register('', ''); ?>.
    
    <?php else : ?> <!-- user can post -->
    
        <!-- handle post submission -->
        <?php if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action']) && $_POST['action'] == 'post') : ?>
    
            <?php check_admin_referer('submit-post') ?>
    
            <?php $post_id = wp_insert_post( array(
                'post_title'    => strip_tags($_POST['posttitle']),
                'post_content'  => $_POST['posttext'],
                'tags_input'    => $_POST['tags']
            ) ); ?>
    
            <?php if ($post_id > 0) : ?>
                <p>Thank you for submitting your post!</p>
                <p>You can still
                <?php edit_post_link( "edit your post", "", "", $post_id ); ?>
                until it's published by the editors.</p>
            <?php else : ?>
                <p>Error saving your post. You can send it by email instead:
                <?php echo get_option('admin_email'); ?>
                </p>
            <?php endif; ?>
    
        <?php else : ?> <!-- show submission form -->
    
            <form id="new_post" name="new_post" method="post" action="<?php the_permalink() ?>">
            <input type="hidden" name="action" value="post" />
            <?php wp_nonce_field( 'new-post' ); ?>
    
            <p>
            <label for="title"><b>Post Title:</b></label><br />
            <input type="text" name="posttitle" id="posttitle" style="width: 99%; font-size: larger;" />
            </p>
    
            <p><b>Author:</b>
                <?php echo $user_identity; ?> &nbsp;
                (<a href="<?php echo wp_logout_url(get_permalink()); ?>">logout</a>)
            </p>
    
            <p>
            <label for="posttext"><b>Post Text:</b></label><br />
            <textarea name="posttext" id="posttext" rows="30" style="width: 99%; font-size: inherit;"></textarea>
            </p>
    
            <p>
            <label for="tags"><b>Tags:</b></label><br />
            <input type="text" name="tags" id="tags" style="width: 99%;" />
            </p>
    
            <input id="submit" type="submit" value="Submit Post" />
            </form>
    
        <?php endif; ?> <!-- submission form -->
    
    <?php endif; ?> <!-- user can post -->
    
    </div>
    </div>
    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>
    Thread Starter shadowpwner

    (@shadowpwner)

    Thanks, but not quite. I have a static page (not related to the blog at all) and it updates once a day. I want to scrape the contents of the page and post it as a post.

    Thanks for responding though!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Creating Simple Plugin to Post To WordPress’ is closed to new replies.