Chiliboy
Member
Posted 4 years ago #
I have been trying to add the comments box to a page (not posts).
I checked the boxes on the sidebar for allow comments and ping. Didn't work.
I read in another post to create a new page template for those pages I wanted to have comments on. I did that and chose that template for the page and saved it. The page won't load. It says error on line 51.
Since I am totally new to WordPress and php I need some help.
Here is the page code I created using the page.php as a start and added the lines for the comments template.
Backticks added as required here to post. They are not part of my page code.
<?php
/*
Template Name: Page With Comments
*/
?>
<?php get_header(); ?>
<div id="content">
<?php include(TEMPLATEPATH."/sidebar.php");?>
<div id="contentmiddle">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- google_ad_section_start -->
<h1><?php the_title(); ?></h1>
<?php /* AdSense Code Start */ ?><?php if ($wp_query->current_post == 0) include("first-ad.php"); ?><?php /* AdSense Code End */ ?>
<?php the_content(__('Read more'));?>
<?php /* Tags WP 2.3 Code Start */ if ( function_exists('is_tag')){ ?>
<p><?php the_tags(); ?></p>
<?php /* Tags WP 2.3 Code End */ } ?>
<!--
<?php trackback_rdf(); ?>
-->
<!-- google_ad_section_end -->
<?php /* AdSense Code Start */ ?><div style="text-align:center; padding-bottom:10px;">
<? include("adsense.php"); ?>
<?php InsertAdvert($PageFooter);?>
</div><?php /* AdSense Code End */ ?>
<?php /* related_posts Start */ ?><?php if (function_exists('related_posts')) { ?><div class="reltpost">
<h3>Related posts to <?php the_title(); ?></h3>
<?php related_posts(); ?>
</div><?php } ?><?php /* related_posts End */ ?>
<h3>Comments on <?php the_title(); ?></h3>
<?php comments_template(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php /* AdSense Code Start */ ?><div style="text-align:center; padding-bottom:10px;">
<? include("adsense.php"); ?>
<?php InsertAdvert($PageFooter);?>
</div><?php /* AdSense Code End */ ?>
Here's your problem
<? include("adsense.php"); ?>
Don't use short php tags. It should be
<?php include("adsense.php"); ?>
Also when pasting large blocks of code like this use http://wordpress.pastebin.ca and give a link to the resulting page here. It keeps things tidy.
Chiliboy
Member
Posted 4 years ago #
Hello Moderator,
Thanks for the heads up on the code pasting thing and the code correction.
Unfortunately, it did
work. Is there a better way to get a comment block onto a page? Maybe a plugin or a widget.
Thanks,
Chiliboy
P.S. Sorry, i left out the word 'not' in my reply.
It's easier to see which line is line 51 if you use http://wordpress.pastebin.ca/ to post the code instead of posting it here.
Chiliboy
Member
Posted 4 years ago #
Hi Again Moderator,
I pasted the code. Here is the link:
http://wordpress.pastebin.ca/920883
What is InsertAdvert($PageFooter);? Where did you get that from? What plugin is that using?
Basically, to make a new Page Template in your theme, it's best to start with one of the templates from your existing theme. Copy page.php to a new name then modify it to make it into a Page Template. If there's no page.php, then you copy your theme's index.php instead. Something along those lines.
Did the starting point for this Template come from the same theme you're using now?
Also what is the exact error message that you receive about line 51?
Chiliboy
Member
Posted 4 years ago #
Hi,
Here is the error message when the page tries to load:
Parse error: syntax error, unexpected $end in /home/content/m/a/j/majorhal2/html/cleaning/wp-content/themes/beautiful-sunrise-adsense-seo-03/page_with_comments.php on line 50
I did copy the page.php template from the the current theme.
This is an adsense and SEO optimized theme I purchased from one of the template uploaders here at WordPress.
I haven't had any trouble with it until I tried to get a comments block inserted into a page.
I took the page.php theme and added the five lines at the top and then the php.comments_template lines.
I really appreciate your help and patience.
Chiliboy
Member
Posted 4 years ago #
Hi,
Has everybody given-up on my problem?
I could really use some help. I need to
post this page within 24 hours - Please.
You still really haven't given us enough information to help you. We can't see all your code. We don't know exactly what you did. Your page template looks like it should work to me, once you fix the <? include error and assuming that InsertAdvert() code is valid somehow. You are missing the call to the footer, but that would not cause an error.
Chiliboy
Member
Posted 4 years ago #
Hello,
Here is the URL. Can you look at all the code that way?
http://yourhomecleaningtips.com/cleaning/contest-entry-page/
I tried to construct a new page template and I made it worse so I switched it back to the default page template.
I am willing to pay a developer, if necessary to get this right.
Best regards,
Chiliboy
No we can't view the code that way you'll need to zip up your theme folder and upload it and give us the link.