• Hello,

    I am creating a site in wordpress that consists of only one single page (index.php). Each section of the page loops and brings in content from a certain post (based on its id). One section also has a comment box as well as the post content, along with posted comments. However, the problem I have is that once a comment has been posted (send button clicked), it loads single.php. The idea is that there are no permalinks on the site and only content of posts are displayed, hence keeping the user on the index page only. What kind go code would I need to add so that posting a comment does not load single.php, and therefore would reload index.php?

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter metallikat79

    (@metallikat79)

    hello again..just some code to give a bit more insight:

    On index.php I am using:

    <?php $category = array('category_name' => 'My category'); ?>
    <?php query_posts($category); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="articleWrap">
            <?php the_content(); ?>
        </div>
        <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>

    and on the section I want the comments box:

    <?php $other_category = array('category_name' => 'My other category'); ?>
    <?php query_posts($other_category); ?>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="articleWrap">
            <?php the_content(); ?>
            <?php $withcomments = 1; comments_template(); ?>
        </div>
        <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>

    The code for my comments template (comments.php) that I call in is:

    <div class="messageBox">
    <?php
    $comments_args = array(
        'comment_notes_after' => '',
        'label_submit'=>'Submit',
        'title_reply' => '',
        'logged_in_as' => '',
        'comment_field' => '<p class="comment-form-comment"><label for="comment"></label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></p>',
    );
    comment_form($comments_args);
    ?>
    </div>  <!-- //messageBox -->
    <div class="commentBoxesWrap">
        <?php wp_list_comments('type=comment&callback=showcomments'); //this is a call back to a function in functions.php ?>
    </div>  <!-- //commentBoxesWrap -->
Viewing 1 replies (of 1 total)
  • The topic ‘Single worspress page with comment box’ is closed to new replies.