• Hi,

    I am relatively new to WordPress – I have just written my first post.

    Could you please help me resolve the following issue:

    I am using the “Emerald Stretch” template on wordpress. Every time someone clicks on “Comment” to leave a comment to a post, the person is taken to the top of the page and they have to scroll down to the comment form to leave a comment.

    And a similar problem when they hit the “Submit” button – instead of the person being taken to the bottom of the post where they can see their comment, they are taken to the top of the page and they have to scroll down to see their comment.

    What code can I use in the template files to change this action. Although I am a beginner I am picking up how to change the code as I go.

    Thanks a lot,

    Lance

Viewing 15 replies - 31 through 45 (of 56 total)
  • I don’t tend to keep too close an eye on what I change, but I can try. The space was caused by using the CSS attribute “visibility” rather than “display”, apparently visibility still leaves a space for the element whereas display controls how it’s aligned with the rest of the document (and takes it out entirely if set to none). The comments weren’t loading because the boolean function is_home() wasn’t working properly. I don’t know why it wasn’t mind you, but it seems to have been returning true rather than false on single blog post pages, whereas it’s only meant to return true on the main blog page. I think the rest of the changes were minor like indenting the code.

    <?php if ( is_home() ) : ?> and <?php endif; ?> are the tags I’m using to make anything inside those tags conditional, you could use pretty much anything with that structure though.
    https://codex.www.ads-software.com/Function_Reference

    If you want to get started on coding in WordPress, the developer documentation and learning about PHP & CSS helps a lot ??

    And yeah, copy and paste, and revert back the changes I made if you want with the instructions down the bottom ?? I think it looks cleaner, but each to their own. I’m not likely to be around in the future ??

    Thread Starter lance007

    (@lance007)

    Perfect. Thanks
    I thought it might be something to do with the “visible” setting. i googled it before. I tried to change it to “collapse”, but that didn’t work.

    I will definitely start learning how to code – will check out the links.

    Why aren’t you going to be around?
    You didn’t say whether you have a blog or company website?

    Lance

    Thread Starter lance007

    (@lance007)

    p.s. who the hell is going to help me if you’re not around. You seem to be the only one on here who knows what he’s doing. Or are you female?
    I don’t believe I ever got your name.

    https://www.w3schools.com/CSS/css_display_visibility.asp

    I’m taking a bit of a break ?? real life matters to attend to

    I run a couple of blogs for people, but I keep those separate from all this

    I’m a he and yes it is a little worrying the quality of code that comes from some users here. Just set up a copy of WordPress and mess around with it, that’s how you learn ?? https://www.apachefriends.org/en/xampp-windows.html#646 – that’s a good simple webserver/database setup for Windows to test on

    You can call me Kawauso, Kawa or Otter. Everyone else does ??

    Thread Starter lance007

    (@lance007)

    Kawauso,

    I just checked out my other pages after I pasted your code and updated. They’re a bit screwed up.
    Would you mind checking them for me.
    The side bars appear to have moved down below the text and the contact form no longer has the Captcha symbols.

    damn.

    Thread Starter lance007

    (@lance007)

    I just cut the code from contact form and re-did it and the captcha seems to be working again. But the side bars are all F.u.

    I can’t reproduce the Captcha symbol problem. If you don’t want comments on pages (I’ve never quite understood why any sane person would), take out comments_template(); from page.php and I think you should be fine. Otherwise… I’m not even sure, there’s something in the mass of divs that make up the page and the comments section that’s causing that.

    hey yall.
    sorry this isnt on topic BUT I NEED HELP.
    recently downloaded wordpress for the site, and it’s not working. i mean:
    i tried to post something, AND NOTHING HAPPENED. i tried to change the theme/template, and NOTHING HAPPENED. i don’t even know where to start or what to try, troubleshootingwise. i’m stumped. does ANYONE have ANY suggestions?!

    Thread Starter lance007

    (@lance007)

    Kawauso,
    I’m not sure I understand. I only want comments on my main postings page. I was talking about the “contact” page and contact form – it seems to be ok now, but the sidebars are all screwed up on my other pages – look at “about lance” and “contact lance” and “disclaimer” pages.

    I took out the comments_template() line in pages.php but that didn’t seem to help.

    I’m dying over here again. please help before you disappear.

    @emee: You’d have to be more specific than that, i.e. what you actually see, etc. Check your file permissions and database settings, and start a new topic, you should have more of a chance of getting help if you make one with a title explaining the problem best you can.

    @lance007: I haven’t the foggiest then. Try taking the code surrounding where the comments_template() call was, but beyond that, I don’t really know. index.php only affects the main page, so there must be something that’s in comments.php which was meant to balance something in page.php, but that’s something only the guy who made the template would really know about and I’m only familiar with the template I work with. Try reverting to an original copy of the comments.php and working from there?

    Thread Starter lance007

    (@lance007)

    Please don’t leave me hanging. I have posted my page.php below. What do you mean “take the code surrounding where comments_template() call was?

    I will also paste the original comments.php below that. I would hate to go back to the original and start all over because it was so screwed up before. We’ve come a long way.

    page.php now:

    <?php get_header(); ?>
    <!-- CONTENT -->
     <div id="content-wrapper">
       <div id="content">
    		<h1 class="pagetitle"><?php the_title(); ?></h1>
    		<?php global $dlPageId; $dlPageId = null;	?>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		  <?php $dlPageId = $post->ID; ?>
    		  <?php the_content(); ?>
      		<center><div style="clear: both;"><?php edit_post_link(__('Edit this page','emerald_stretch'), '<p>', '</p>'); ?></div></center>
    		<?php endwhile; endif; ?>
      </div>
    <!-- /CONTENT -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    original comments.php:

    <?php
    	if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die (__('Please do not load this page directly.', 'emerald_stretch'));
    
            if (!empty($post->post_password)) {
                if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {
    				?>
    				<p><?php _e('This post is password protected. Enter the password to read comments.', 'emerald_stretch'); ?></p>
    				<?php
    				return;
                }
            }
    		$oddcomment = 'alt';
    ?>
    
    <div id="comments">
    	<?php if ($comments) : ?>
    		<h1><?php comments_number(__('No Responses','emerald_stretch'), __('One Response','emerald_stretch'), __('% Responses','emerald_stretch')); //_e(' to “','emerald_stretch'); the_title(); _e('”', 'emerald_stretch'); ?></h1>
    		<div id="comment-area">
    			<ol>
    			<?php foreach ($comments as $comment) : ?>
    				<li class="<?php echo $oddcomment; ?> <?php if (function_exists('author_highlight')) { ?> <?php author_highlight(); ?><?php } ?>" id="comment-<?php comment_ID() ?>">
    
    					<p class="commenter"><?php echo get_avatar( $comment, 48 ); ?> <?php comment_author_link() ?><span class="comment-info"> - <?php comment_date(__('F j, Y', 'emerald_stretch')) ?></span></p>
    					<?php if ($comment->comment_approved == '0') : ?>
    						<span class="comment-moderation"><?php _e('??¢??¢??¢ Your comment is awaiting moderation ??¢??¢??¢', 'emerald_stretch'); ?></span>
    					<?php endif; ?>
    					<?php comment_text() ?>
    				</li>
    
    				<?php
    					if ('alt' == $oddcomment) $oddcomment = '';
    					else $oddcomment = 'alt';
    				?>
    
    			<?php endforeach; ?>
    			</ol>
    		</div>
    
    	<?php if ('closed' == $post->comment_status) : ?>
    		<!-- <h3><?php _e('Comments are closed for this entry.', 'emerald_stretch'); ?></h3> -->
    		</div>
    	<?php endif; ?>
    
    	<?php else : ?>
    		<?php if ('open' == $post->comment_status) : ?>
    		<?php else : ?>
    			<!-- <h3><?php _e('Comments are closed for this entry.', 'emerald_stretch'); ?></h3> -->
      		</div>
    		<?php endif; ?>
    	<?php endif; ?>
    
    	<?php if ('open' == $post->comment_status) : ?>
    		<div id="comment-form">
    			<h1><?php _e('Leave a Reply', 'emerald_stretch'); ?></h1>
    			<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
          <p><?php _e('You must be', 'emerald_stretch'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>"><?php _e('logged in', 'emerald_stretch'); ?></a><?php _e(' to post a comment', 'emerald_stretch'); ?>.</p>
    		</div>
    	<?php else : ?>
    		<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    			<?php if ( $user_ID ) : ?>
            <p><?php _e('Logged in as', 'emerald_stretch'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <?php wp_loginout(); ?>.<!-- <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account', 'emerald_stretch'); ?>"><?php _e('Log out &raquo;', 'emerald_stretch'); ?></a> --></p>
    			<?php else : ?>
            <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="30" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
            <label for="author"><?php _e('Name', 'emerald_stretch'); ?><?php if ($req) _e(', required', 'emerald_stretch'); ?></label></p>
            <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="30" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
            <label for="email"><?php _e('Email (will not be published)', 'emerald_stretch'); ?><?php if ($req) _e(', required', 'emerald_stretch'); ?></label></p>
            <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="30" tabindex="3" />
            <label for="url"><?php _e('Website (if present)', 'emerald_stretch'); ?></label></p>
    			<?php endif; ?>
    				<p><textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea></p>
    				<?php do_action('comment_form', $post->ID); ?>
    				<p>
    					<input name="submit" class="button" type="submit" id="submit" tabindex="5" value="<?php _e('Submit', 'emerald_stretch'); ?>" />
    					<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    				</p>
    		</form>
    	</div>
    	<?php endif; ?>
    </div>
    <?php endif; ?>

    You’re probably missing a </div> before the <!-- /CONTENT -->. There are three opening <div> tags and two closing. Else, no idea. I’m not even attempting to trace the opening and closing in the comments template. Programmer’s Notepad makes it more readable though btw.

    Thread Starter lance007

    (@lance007)

    hmmm – check it out now – that did something strange – it got rid of my tabs for “home” “about lance” etc… and didn’t fix the problem.

    HELP

    what is Programmer’s Notepad

    Who knows… your theme doesn’t seem to behave how it should, because that change shouldn’t have affected the entire blog. Try a different theme or something, but I can’t help anymore sorry.

    It’s a program.

Viewing 15 replies - 31 through 45 (of 56 total)
  • The topic ‘When click on comments link the reader is taken to the top of the page’ is closed to new replies.