• I would like to use the have no comment php command to write a brief italicized message as to what the comment should contain on pages where no comment is already written. theme is stripay. all other pages with comments already written should display as is with the comments and without the direction. any help is greatly appreciated as i have already googled as much as i can and am using this as a last resort. thanks to anyone who can lead me in the right direction this is a critical element to my site.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Would get_comments() work in your case?

    <?php
     if ( !get_comments() ) {
      //message
     }
    ?>

    http://codex.wordpress.org/Function_Reference/get_comments

    Thread Starter King818

    (@king818)

    Is there a specific way I should use it? I have looked through the document but couldn’t locate the part I needed.

    Thread Starter King818

    (@king818)

    Anyone? This is an integral part of my site as it is comment dependant. Thanks guys. If you have any leads at all please let me know.

    Thread Starter King818

    (@king818)

    For anyone incoming off of Google and wishing to learn how to do this, I managed to figure out a legitimate workaround.

    I ended up using ‘comments_popup_link’ and used it as follows:

    <?php comments_popup_link('</a>NO COMMENT MESSAGE DISPLAY TEXT GOES HERE', '<div style="visibility: hidden"> </div>', '<div style="visibility: hidden"> </div>'); ?>

    The way this works is by using a code which displays how many comments the page currently has, and then linking to the pages leave a comment field. You have three fields in the ”,”,”, and by default they are ‘0 comments’,’1 comment’,’% commments’. I used a visibility hidden code to kill the last two fields, and then replaced the default 0 comments with my display text. I also before displaying the text put a </a> attribute which killed the link which would otherwise show up and link you to leaving a comment for the page.

    I then placed this in comments.php, in my case line 70.

    Done!

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

The topic ‘?php if ( have_comments() ) : ?’ is closed to new replies.