• Resolved andymike

    (@andymike)


    Ok I think I need an “if” PHP statement. I am a real beginner with PHP. I want this chunk of code from my comments.php to parse only if there is at least one comment:

    <h3 class="commentstop"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?>
    <?php if ( comments_open() ) : ?>
    <a id="leavecomment" href="#postcomment" title="<?php _e("Leave a comment"); ?>">Leave A Comment</a>
    <?php endif; ?></h3>

    So the PHP I need in English:

    [ IF THERE ARE NO COMMENTS SKIP THIS CODE] [ IF THERE IS AT LEAST 1 COMMENT PARSE IT NORMALLY]

    It should be relatively simple I just don’t know any PHP.

    Thanks for any help you can give 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • michael_

    (@michael_)

    Try this one:

    if ( $comments ) {
    echo 'There is at least one comment';
    } else {
    echo 'No comment here';
    }

    Thread Starter andymike

    (@andymike)

    Thanks!

    I actually found some similar PHP later in the comments code that worked perfectly. I just used:

    <?php if ( $comments ) : ?>

    CODE HERE

    <?php else : // If there are no comments yet ?>
    <?php endif; ?>

    Worked like a charm!

    resiny

    (@resiny)

    I suck at php. I can hack my way around, but I really need to learn to do custom variables for myself…I need stuff like this all the time

    Kafkaesqui

    (@kafkaesqui)

    resiny

    (@resiny)

    yeah, yeah, I know. I just need the motivation. There are tons of sites out there with great tutorials…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Help Needed Please’ is closed to new replies.