• I would like to be able to link in a page/template for posting new comments rather than having the comment form fields just appear inline at the bottom of the single.php template.

    That is, on a typical single.php template, one would see an article, comments on that article and, at the bottom, several fields for posting one’s own comment. I would like to put the posting feature on its own page. When the comment is submitted, I want the user to be taken back to the article page.

    I tried linking in my comments page like this:

    <li><a href="<?php bloginfo('template_directory'); ?>/articles_comments.php">Write A Comment</a></li>

    But the resulting url breaks all the links in my includes.

    Additionally, I would also like to have a link to a page that only displayed the comments on an article.

    And, while I’m dreaming, I would like to be able to save a comments field for the user’s physical location (that is, the state/city the are from).

    Any tips? I’ve been searching to see if anyone else does this and I couldn’t find anything. Thank you for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter nateomedia

    (@nateomedia)

    Bump. Anyone able to shed some light on this? I’ve found info on how to add fields to display the user’s location, but not the rest. Thanks.

    Thread Starter nateomedia

    (@nateomedia)

    I figured it out. Simple trick, actually. Basically, I put an if statement on the single.php page and used $_GET to determine what part of the post got displayed (ie, article, comments, or coment form). Here’s the basic structure:

    <?php while ( have_posts() ) : the_post(); ?>
    <?php if ( ( $_GET['read'] == NULL ) && ( $_GET['write'] == NULL ) ) { ?>
    <?php the_content(); ?>
    <?php } elseif ( $_GET['write'] == 'true' ) {
    if ('open' == $post->comment_status) { ?>
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="f_article_comment">
    <?php do_action('comment_form', $post->ID); ?>
    </form>
    <?php }
    }
    if ( $_GET['write'] == NULL ) { ?>
    <?php comment_text(); ?>
    <?php } endwhile; ?>

    Then, to pass write or read to the url, create your links like this:

    <li><a href="index.php?p=<?php echo $_GET['p']; ?>&read=true">Read Comments Made</a></li>
    <li><a href="index.php?p=<?php echo $_GET['p']; ?>&write=true">Write A Comment</a></li>

    Voila!

    Still working out some small issues … trying to figure out how to pull write=true from the url after a comment is submitted. Need to do a little more tinkering.

    Haven’t actually implemented the custom comment field yet… the solutions I’ve seen require changing the wp code… maybe it time to learn how to make a pluggin (if this is possible).

    Thread Starter nateomedia

    (@nateomedia)

    Ah, very simple. Just add this to the form:

    <input type="hidden" name="redirect_to" value="index.php?p=<?php echo $id; ?>" />

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create a non-inline comments form?’ is closed to new replies.