Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #162292

    Is there a way to add comments to just one page? I see the instructions for adding comments to all pages. But I just want to enable them on one page. Thx.

    #162397

    I’ve done a bit of investigating the support area here. Based on what I read, since I wanted to just have comments on some pages but not all, I created another template based on the page.php template. I put the following code for comments as was suggested elsewhere:

    <div>		
    		// wordpress function that loads the comments template "comments.php" 
    comments_template( '/includes/comments.php');
    
    echo "</div><!--end inner_box-->";	

    But the comments didn’t show up. The instructions say to replace
    echo "</div><!--end inner_box-->";
    with the code above. But I didn’t find this code in my page.php file.

    Here is my page.php file. Could you tell me where to put the code to enable comments with this new template:

    
    <?php 
    /* 
    Template Name: Page_With_Comments
    */
    global $avia_config;
    
    	/*
    	 * check which page template should be applied: 
    	 * cecks for dynamic pages as well as for portfolio, fullwidth, blog, contact and any other possibility :)
    	 * Be aware that if a match was found another template wil be included and the code bellow will not be executed
     	 * located at the bottom of includes/helper-templates.php
    	 */
    	 avia_get_template();
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */	
    	 get_header();
     	 
    	?>
    		
    		<!-- ####### MAIN CONTAINER ####### -->
    		<div id='main'>
    		
    			<div class='template-page'>
    
    				<div class='content <?php echo $avia_config['content_class']; ?> units'>
    
    				<?php
    				/* Run the loop to output the posts.
    				* If you want to overload this in a child theme then include a file
    				* called loop-page.php and that will be used instead.
    				*/
    				$avia_config['size'] = 'page';
    				get_template_part( 'includes/loop', 'page' );
    				?>
    				
    					
    				<!--end content-->
    				</div>
    		
    				
    			</div><!--end template-->
    
    	</div>
    	<!-- ####### END MAIN CONTAINER ####### -->
    
    </div>
    <?php 
    
    	//get the sidebar
    	$avia_config['currently_viewing'] = 'page';
    	get_sidebar();
    				
    ?>
    </div>				
    
    <?php get_footer(); ?>
    
    • This reply was modified 10 months, 1 week ago by  outtacontext.
    #162721

    Hi,

    Do the following changes above then edit the page, click Screen Options > enable Discussions. You uncheck “Allow Comments” if you don’t want to show a comment box on that particular page.

    Set the default settings on Settings > Discussions.

    Regards,
    Ismael

    #162902

    I tried your suggestion. The comments didn’t show up. Here’s the situation:

    1. In Settings > Discussion Settings, the box next to Allow people to post comments on new articles was already checked.
    2. I set the particular article’s template to my updated new template (see template code below (is the new code in the right place?)
    3. I went to Screen Options and selected both Discussions and Comments (I also tried enabling only Discussion but neither choices enabled the Comments.

    This is what I got at the bottom of my page:

    Screenshot of Page

    Here is the template I created to enable comments (based on the page.php template):

    
    <?php 
    /* 
    Template Name: Page_With_Comments
    */
    global $avia_config;
    
    	/*
    	 * check which page template should be applied: 
    	 * cecks for dynamic pages as well as for portfolio, fullwidth, blog, contact and any other possibility :)
    	 * Be aware that if a match was found another template wil be included and the code bellow will not be executed
     	 * located at the bottom of includes/helper-templates.php
    	 */
    	 avia_get_template();
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */	
    	 get_header();
     	 
    	?>
    		
    		<!-- ####### MAIN CONTAINER ####### -->
    		<div id='main'>
    		
    			<div class='template-page'>
    
    				<div class='content <?php echo $avia_config['content_class']; ?> units'>
    
    				<?php
    				/* Run the loop to output the posts.
    				* If you want to overload this in a child theme then include a file
    				* called loop-page.php and that will be used instead.
    				*/
    				$avia_config['size'] = 'page';
    				get_template_part( 'includes/loop', 'page' );
    				?>
    				
    <div>		
    		// wordpress function that loads the comments template "comments.php" 
    comments_template( '/includes/comments.php');
    
    echo "</div><!--end inner_box-->";	
    
    				<!--end content-->
    				</div>
    <div>		
    		</div>		
    				
    			</div><!--end template-->
    
    	</div>
    	<!-- ####### END MAIN CONTAINER ####### -->
    
    </div>
    <?php 
    
    	//get the sidebar
    	$avia_config['currently_viewing'] = 'page';
    	get_sidebar();
    				
    ?>
    </div>				
    
    <?php get_footer(); ?>
    

    Remember, I mentioned that your instructions said to replace

    
    echo "</div><!--end inner_box-->";
    

    with the new code. But there was NO occurrence of the code above in my pages template to begin with.

    Here’s a link to the page in question: http://outtacontext.com/articles/uneventful-the-rise-of-photography/

    #163105

    Update: I got it to work but only after I looked again throughout this forum and found Josue’s recommendation in this thread: http://www.kriesi.at/support/topic/comments-arent-shown-in-pages/ He said:

    Open the page.php file and look for this line (26):

    get_template_part( ‘includes/loop’, ‘page’ );

    Add this one just after it:

    comments_template( ‘/includes/comments.php’);

    Final code:

    get_template_part( ‘includes/loop’, ‘page’ );

    comments_template( ‘/includes/comments.php’);

    Regards,

    Josue

    This gave me clear directions on where to put the call to the comments.php include. I followed it and with your help in setting up discussions, it works just fine now.

    #163305

    Hi!

    Yes, your first code is incorrect. Glad it is working now.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Adding Comments on Just One Page’ is closed to new replies.