Support » Fixing WordPress » PHP code reset, please see if anything noticeably wrong in the code!

  • Resolved PauloCot

    (@paulocot)


    Guys I’ve had an absolute nightmare, for one reason or another I have reset my comments.php and page.php code to the original that came with the theme and can’t figure out for the life of me what has changed. The problem is the comments aren’t displaying on ‘pages’ anymore. The page should entail the page title and then the list of comments for that page (that’s how my site works) but at the moment it is only showing the title.

    I have included in page.php because before I reset the files I had edited something in there to make comments display on all pages – maybe that’s the route of the problem? Unfortunately I cannot see where an error is on page.php

    Another reason it might not be working is I removed snippets of code from the comments.php such as the original wordpress comment system forms. Once again though I’m not a coding level to be able to identify the problem.

    Below is my code for page.php and comments.php – would be very appreciative if anyone can pick up on why this code would cause the comments not to show. For your information I’m using the jetpack wordpress comment system; even when I revert back the original wordpress comment system the same problem happens.

    page.php :

    <div class="wrapper">
    
    <div id="main">
    
        <div id="content">
    
            <?php
            wp_reset_query();
    
            if ( have_posts() ) :
    
                while ( have_posts() ) :
    
                    the_post();
    
                    ?><h1><a href="<?php the_permalink(); ?>"     rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
                    <p class="postmetadata"><?php edit_post_link( __('EDIT', 'wpzoom'), '', ''); ?></p>
    
                    <div class="postcontent">
    
                        <?php
                        the_content();
    
                        wp_link_pages( array( 'before' => '<p class="pages"><strong>'.__('Pages', 'wpzoom').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number' ) );
                        ?>
    
                        <div class="cleaner"> </div>
    
                    </div><!-- end .postcontent --><?php
    
                endwhile;
    
            else:
    
                ?><p><?php _e('Sorry, no posts matched your criteria.', 'wpzoom'); ?></p><?php
    
            endif;
            ?>
    
        </div><!-- end #content -->
    
    </div><!-- end #main -->
    
    <div id="sidebar">
    
        <?php get_sidebar(); ?>
    
    </div><!-- end #sidebar -->
    
    </div><!-- end .wrapper -->
    
    <?php get_footer(); ?>

    comments.php :

    <?php
    // Do not delete these lines
        if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
            die ('Please do not load this page directly. Thanks!');
    
        if ( post_password_required() ) { ?>
            <p class="nocomments">This post is password protected. Enter the password to view comments.</p>
        <?php
            return;
        }
    ?>
    
    <!-- You can start editing here. -->
    
    <?php if (have_comments()) { ?>
      <div id="commentspost"><a name="commentspost"></a>
        <ol class="normalComments"><?php wp_list_comments('type=all&avatar_size=60');?></ol>
        </div><!-- end #commentspost -->
    <?php if ('closed' == $post->comment_status) : ?>
    <?php endif; ?>
    
     <?php }
     else { // this is displayed if there are no comments so far ?>
    
        <?php if ('open' == $post->comment_status) { ?>
            <!-- If comments are open, but there are no comments. -->
    <div id="commentspost">
        <h2 class="title">0 <?php _e('Comments', 'wpzoom'); ?></h2>
      <p><?php _e('You can be the first one to leave a comment', 'wpzoom'); ?>.</p>
    </div>
         <?php } else { // comments are closed ?>
            <!-- If comments are closed. -->
        <?php } ?>
    <?php } ?>
    
    <?php if ('open' == $post->comment_status) : ?>
    
    <div id="respond">
    <h2 class="title"><?php comment_form_title( __('Leave a Comment', 'wpzoom'), __('Leave a Reply to %s', 'wpzoom') ); ?></h2>
    <div class="cleaner"> </div>
    <div class="cancel-comment-reply"><p><?php cancel_comment_reply_link(); ?></p></div>
    
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    <p><?php _e('You must be', 'wpzoom'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>"><?php _e('logged in', 'wpzoom'); ?></a> <?php _e('to post a comment.', 'wpzoom'); ?></p>
    <?php else : ?>
    
    <?php comment_form(); ?>
    
    <?php if ( $user_ID ) : ?>
    
    <p><?php _e('Logged in as', 'wpzoom'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account"><?php _e('Log out', 'wpzoom'); ?> »</a></p>
    
    <?php comment_id_fields(); ?>
    <?php do_action('comment_form', $post->ID); ?>
    </form>
    <?php endif; // If registration required and not logged in ?>
    </div>
    
    <?php endif; // if you delete this the sky will fall on your head ?>

    Any help would be much appreciated, can’t believe I’ve done it…

    Cheers, Paul

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    Where did you get this theme? The simplest way to get your comments back is just to restore the original copies of those files.

    The theme is photoria. That’s the issue, I had the comments working perfectly. I had edited the code in page.php / comments.php so every page would display the number of comments (comment count) i.e. adding the comment count function to page.php . I did this because the way my site works every page with the exception of one would display comments.

    I then stupidly reset the whole theme and now I have this problem!

    Don’t worry guys, have managed to fix it!

    page.php wasn’t calling comments_template(); where as single.php (posts) was. Just copied the code over and it is fine!

    Friends,

    I wanted to delete the headers of pages saying You are browsing now…
    I consulted the forum and I tried to fix it but it didn’t work
    I understand I accidentaly deleted a part in archive.php
    Now it is written on the top of the pages the following :

    Parse error: syntax error, unexpected $end in /home/asanatco/public_html/yesiltepe.com/wordpress/wp-content/themes/custom-community/archive.php on line 121

    I will be happy if you can help me, Thank you

    Necip

    WPyogi

    (@wpyogi)

    Forum Moderator

    @anecipyesiltepe – Download a new copy of the theme to your local computer – and then replace that file using FTP or other file manager your host uses. Also, you should not modify theme files – but instead use a Child Theme for these kinds of modifications –

    http://codex.wordpress.org/Child_Themes

    If you need additional help, you need to start your own thread – this one is resolved and not the same issue. For help with your theme, please post here:

    http://wordpress.org/support/theme/custom-community

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP code reset, please see if anything noticeably wrong in the code!’ is closed to new replies.