WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP: How to get "is visitor on comments page" ? (3 posts)

  1. Michael_
    Member
    Posted 8 years ago #

    I am creating a template for myself and am having a little issue:
    In index.php, I am displaying stuff like:
    Category: bla | Comments (2)
    Please note the pipe symbol (|).
    I am using "the_category()" and "comments_popup_link()" for displaying both the cat and the comments link. But if a visitor clicks "Comments (2)" and the comments are being displayed, it is looking weird since there is a | after the category:
    Category: bla |

    I want to remove this pipe if visitor is viewing comments.

    So far I use:
    <?php the_category(', ') ?> | <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>

    How can I find out via PHP whether the comments are being displayed or not?
    I'd like to have something like this:
    if (is_visitor_on_comment_page) {
    $isoncomment = true;
    } else {
    $isoncomment = false;
    }
    so that I can control what to display and so that I can hide this pipe symbol when visitor is on comment page.

    Checking comments_popup_link for true/false or for isempty() does not work.

    Thanks in advance,
    Michael

  2. moshu
    Member
    Posted 8 years ago #

    See all the conditional tags here: http://codex.wordpress.org/Conditional_Tags
    There isn't really a "comment" page - more likely you are talking about the single post view...

  3. Michael_
    Member
    Posted 8 years ago #

    Great, thanks moshu, I am sure this will help.

    >> There isn't really a "comment" page - more likely you are talking about the single post view...

    Yes, you're right, that's what I have meant, I just do not know the WordPress wording yet ;-)

    Thanks again,
    Michael

Topic Closed

This topic has been closed to new replies.

About this Topic