Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter fallenmedia

    (@fallenmedia)

    I am pretty sure the issue lies here:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    What do I have to change to show posts with postname permalinks?

    Thread Starter fallenmedia

    (@fallenmedia)

    Thank you@!

    Thread Starter fallenmedia

    (@fallenmedia)

    Does anybody know what I’m talking about? Am I over thinking this?

    Thread Starter fallenmedia

    (@fallenmedia)

    How do you enter line breaks?

    Because right now spaced out like this:

    This is a comment
    Comment posted by

    Author1This is a comment
    Comment posted by

    Author2This is another comment
    Comment posted by

    Author

    Other than that it works perfectly

    Thread Starter fallenmedia

    (@fallenmedia)

    Hey,
    The above code gives me this error:
    Parse error: syntax error, unexpected T_ECHO, expecting ‘,’ or ‘;’ in /home/manbartz/public_html/blog.php on line 106

    Line 106 – echo '<p>Comment posted by</p>

    Thread Starter fallenmedia

    (@fallenmedia)

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('blog/wp-blog-header.php');
    ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
     <!-- Test if the current post is in category 3. -->
     <!-- If it is, the div box is given the CSS class "post-cat-three". -->
     <!-- Otherwise, the div box is given the CSS class "post". -->
    
     <?php if ( in_category('3') ) { ?>
               <div class="post-cat-three">
     <?php } else { ?>
               <div class="post">
     <?php } ?>
    
     <!-- Display the Title as a link to the Post's permalink. -->
    
     <h2 style="font-size: 20px;"><?php the_title(); ?></h2>
    
     <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
    
     <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
    
     <!-- Display the Post's content in a div box. -->
    
     <div class="entry">
       <?php the_content(); ?>
     </div>
    
     <!-- Display a comma separated list of the Post's Categories. -->
    
     <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
     </div> <!-- closes the first div box -->
    
    <!-- Comment below -->
    
    <h3><?php
    $comments = get_comments('post_id=15');
    foreach($comments as $comment) :
    	echo($comment->comment_content);
    endforeach;
    ?></h3>
    <p>Comment posted by
    <?php
    $comments = get_comments('post_id=15');
    foreach($comments as $comment) :
    	echo($comment->comment_author);
    endforeach;
    ?>
    </p>
    
     <!-- Stop The Loop (but note the "else:" - see next line). -->
    
     <?php endwhile; else: ?>
    
     <!-- The very first "if" tested to see if there were any Posts to -->
     <!-- display.  This "else" part tells what do if there weren't any. -->
     <p>Sorry, no posts matched your criteria.</p>
    
     <!-- REALLY stop The Loop. -->
     <?php endif; ?>
    Thread Starter fallenmedia

    (@fallenmedia)

    Now it’s showing the author name 3 times… I cant link you to anything right now, but using that exact comment_author snippet above from the get_comments wpcodex page results in this for some reason:

    Comment 1Comment 2Comment 3
    Comment posted by AndrewAndrewAndrew

    It is displaying multiple comments on one line too, I just noticed this.

    Thread Starter fallenmedia

    (@fallenmedia)

    Sweet, if I could buy you a beer I would.

    For the comment_author snippet, why is it posting the author name twice?

    Thread Starter fallenmedia

    (@fallenmedia)

    Thanks Graphical,

    I inserted that code, and tested a comment with it. It only displays the comment author.

    I’m pretty new with PHP.

    Thread Starter fallenmedia

    (@fallenmedia)

    Let me know if you want the surrounding html

    Thread Starter fallenmedia

    (@fallenmedia)

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('blog/wp-blog-header.php');
    ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
     <!-- Test if the current post is in category 3. -->
     <!-- If it is, the div box is given the CSS class "post-cat-three". -->
     <!-- Otherwise, the div box is given the CSS class "post". -->
    
     <?php if ( in_category('3') ) { ?>
               <div class="post-cat-three">
     <?php } else { ?>
               <div class="post">
     <?php } ?>
    
     <!-- Display the Title as a link to the Post's permalink. -->
    
     <h2 style="font-size: 20px;"><?php the_title(); ?></h2>
    
     <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
    
     <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
    
     <!-- Display the Post's content in a div box. -->
    
     <div class="entry">
       <?php the_content(); ?>
     </div>
    
     <!-- Display a comma separated list of the Post's Categories. -->
    
     <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
     </div> <!-- closes the first div box -->
    
     <!-- Stop The Loop (but note the "else:" - see next line). -->
    
     <?php endwhile; else: ?>
    
     <!-- The very first "if" tested to see if there were any Posts to -->
     <!-- display.  This "else" part tells what do if there weren't any. -->
     <p>Sorry, no posts matched your criteria.</p>
    
     <!-- REALLY stop The Loop. -->
     <?php endif; ?>
    Thread Starter fallenmedia

    (@fallenmedia)

    Thread Starter fallenmedia

    (@fallenmedia)

    http://50.87.152.103/~autotech/

    Blog is on the bottom 🙂

    Thanks for your help graphical

    Thread Starter fallenmedia

    (@fallenmedia)

    Probably misunderstanding you, but I have successfully used the above code to display my blog posts on my existing website… I just want to display comments… really, no way?

    Thread Starter fallenmedia

    (@fallenmedia)

    If you are using WordPress stuff, the pages will be WordPress. Meaning you can’t use pieces of it like the loop, in the way that you want. You can’t call the loop and have it display on your non WordPress site. It will have to be a theme.

    Thanks for your reply.

    What if I created a testimonials category, and displayed the comments on my non-wp site.

    <?php if ( in_category('3') ) { ?>
               <div class="post-cat-three">
     <?php } else { ?>
               <div class="post">
     <?php } ?>

    Is there php code where I can have it display comments from a specific category?

Viewing 15 replies - 1 through 15 (of 15 total)