• Resolved pappe

    (@pappe)


    Hello!

    I′ve tried everything. I search for a couple of days now and have tried any written tip founded but nothing solve my problem. So I hope to find a wordpress expert here who knows the answer …

    The Problem:
    When I add a comment a 404 error is the result. The URL after clicking the “submit” button is wrong:

    https://hoffmann-bauunternehmen.de/http%3A%2F%2Fhoffmann-bauunternehmen.de%2Fgaestebuch%2F#comment-48

    If you want to trie the comments function use this site please:

    guestbook

    When I activate the standard theme comments works correctly. The theme author is no real help, so I hope to get a working solution here. The theme I use is the commercial horizon theme, to find here:

    https://horizon.webtemplatemasters.com/

    The comments.php looks like this:

    <?php
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die ('Please do not load this page directly.');
    
    	if ( post_password_required() ) { ?>
    		<h4 class="nocomments"><?php _e('This post is password protected. Enter the password to view comments.', 'horizon') ?></h4>
    	<?php
    		return;
    	}
    
    //Comments List
    
    	 if ( have_comments() ) : // if there are comments ?>
    	 <!-- post comments -->
        <div class="comment-list" id="comments">
    		<h4><?php comments_number( '0 '.__('Comments','horizon'), '1 '.__('Comment','horizon'), '% '.__('Comments','horizon')); ?></h4> 
    
    <ol>
    		<?php wp_list_comments('avatar_size=100&callback=tmk_comment'); ?>
    		</ol>
    	</div><!--/ #comments-->
     <!--/ post comments -->
     <?php
    
    //Comments error messages
    
    		if ('closed' == $post->comment_status ) : // if the post has comments but comments are now closed ?>
    
    		<?php endif; ?>
    
     		<?php else :  ?>
    
            <?php if ('open' == $post->comment_status) : // if comments are open but no comments so far ?>
    
            <?php else : ?>
    
            <?php endif; ?>
    
    <?php endif;
    
    //Contact Form
    
    	if ( comments_open() ) : ?>
    	<!-- add comment -->
    	<div class="add-comment" id="addcomments">
    		<h4><?php _e('Leave a Reply','horizon'); ?></h4>
    		<div class="comment-form">
    			<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    			<?php printf('<p>'.__('You must be %1$slogged in%2$s to post a comment.', 'horizon').'</p>', '<a href="'.get_option('siteurl').'/wp-login.php?redirect_to='.urlencode(get_permalink()).'">', '</a>') ?>
    			<?php else: ?>
    			<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    				<?php if ( is_user_logged_in() ) : ?>
    				<p><?php printf(__('Logged in as %1$s. %2$sLog out ?%3$s', 'horizon'), '<a href="'.get_option('siteurl').'/wp-admin/profile.php">'.$user_identity.'</a>', '<a href="get_option('siteurl').'/wp-login.php?action=logout" title="').'">', '</a>') ?></p>
    				<?php else : ?>
    				<div class="row">
    					<input type="text" name="author" id="author" value="" class="inputtext required" />
    					<label><?php _e('Your Name','horizon'); ?>: <span>(<?php _e('required','horizon'); ?>)</span></label>
    				</div>
    				<div class="row">
    					<input type="text" name="email" id="email" value="" class="inputtext required" />
    					<label><?php _e('E-mail','horizon'); ?>: <span>(<?php _e('will not be published','horizon'); ?>)</span> <span>(<?php _e('required','horizon'); ?>)</span></label>
    				</div>
    				<div class="row">
    					<input type="text" name="url" id="url" value="" class="inputtext required" />
    					<label><?php _e('Website','horizon'); ?></label>
    				</div>
    				<?php endif; ?>
    				<div class="row">
    					<textarea cols="30" rows="10" name="comment" id="comment" class="textarea textarea_middle required"></textarea>
    				</div>
    				<input type="hidden" value="<?php echo urlencode(get_permalink()); ?>" name="redirect_to" id="redirect_to" />
    				<div class="row">
    					<input type="submit" value="Submit" class="button default small" />
    				</div>
    				<?php comment_id_fields(); ?>
    				<?php do_action('comment_form', $post->ID); ?>
    			</form>
    			<?php endif; ?>
    		</div><!--/ comment-form-->
    	</div><!--/ addcomments-->
    	<!--/add comment -->
    	<?php endif; ?>

    Thanks!

    Martin

Viewing 4 replies - 1 through 4 (of 4 total)
  • popper

    (@julialasarte)

    On your comments form, you have this field:

    <input type="hidden" value="http%3A%2F%2Fhoffmann-bauunternehmen.de%2Fgaestebuch%2F" name="redirect_to" id="redirect_to">

    that’s what’s giving you trouble. Remove the encoded chars :

    <input type="hidden" value="https://hoffmann-bauunternehmen.de/gaestebuch/" name="redirect_to" id="redirect_to">

    Thread Starter pappe

    (@pappe)

    Thanks for reply. In the comments.php line 71 there is this code:

    <input type="hidden" value="<?php echo urlencode(get_permalink()); ?>" name="redirect_to" id="redirect_to" />

    The string value=”http%3A%2F%2Fhoffmann-bauunternehmen.de%2Fgaestebuch%2F” I can not find ?!?

    popper

    (@julialasarte)

    Ah, it isn’t hardcoded. Couldn’t tell that from the outputted code.

    You have to options. You can either change:

    <input type="hidden" value="<?php echo urlencode(get_permalink()); ?>" name="redirect_to" id="redirect_to" />

    to

    <input type="hidden" value="<?php echo get_permalink(); ?>" name="redirect_to" id="redirect_to" />

    And see how that goes or leave it like that and decode it before using it. You should search for a function in your theme that uses something like $_POST['redirect_to'].

    Thread Starter pappe

    (@pappe)

    Thaaaaanks a lot – the odyssey has an end!

    I changed line 71 as you suggested and that solved the problem!

    Have a nice evening!

    Martin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘comments 404 error – never ending story’ is closed to new replies.