WordPress.org

Ready to get started?Download WordPress

Forums

Permalinks and Comments (16 posts)

  1. teccus
    Member
    Posted 8 years ago #

    I'm having a problem with my Permalinks and Comments. At the moment I'm using single.php to pull in my comments.php template. I've set it up so that my single.php doesn't display the_content() so it just shows up my comments, but this doesn't help when I want single.php to generate the permalink page..

    Is there any type of IF clause I can enter into single.php so that when you come from a comments link it displays the comments template and when you come from the permalink it displays the_content and not the comments?

  2. maerk
    Member
    Posted 8 years ago #

    Hmm... not sure about that one. Was there a problem with having post and comment on the same page?

    You might try adding something like ?only_comments=true to the end of the link, and then in your single.php, checking for this using:

    <?php if ("true" == $_GET['only_comments']) : ?>
    <!-- don't show posts -->
    <?php else : ?>
    <!-- Do show posts! -->
    <?php endif; ?>

  3. teccus
    Member
    Posted 8 years ago #

    Brilliant, that's what I had in my head, but I wasn't sure about the coding! I'll give it a go..

  4. teccus
    Member
    Posted 8 years ago #

    OK. I'm a bit stuck..

    The URL i end up with is: http://www.mysite.com/index.php/2006/this-is-a-test/?only_comments=true

    But I'm getting a 500 server error.. What am I doing wrong?

  5. maerk
    Member
    Posted 8 years ago #

    Oh, you have funny permalinks :(

    If the permalinks have index.php in them, I think things are a bit more difficult...

    You're on a Windows server, right?

  6. teccus
    Member
    Posted 8 years ago #

    Yep, Yahoo Hosting with no access to .htaccess :-/

  7. teccus
    Member
    Posted 8 years ago #

    I've got it not not server errroring with 500 now. I'm going to have a play, will post back later if I get a result.

  8. maerk
    Member
    Posted 8 years ago #

    OK try this:

    stick /comments-only/ to the end of the link, and then in your PHP put this:

    <?php if ( strpos ($_SERVER['REQUEST_URI'], "comments-only") : ?>
    <!-- don't show posts -->
    <?php else : ?>
    <!-- Do show posts! -->
    <?php endif; ?>

    But be warned, that will match any URL containing the string "comments-only". Also, I'm not sure that it won't throw a 404 Not Found :S

  9. teccus
    Member
    Posted 8 years ago #

    What I've done is modified my permalink to:

    http://www.mysite.com/?p=32?comments=true

    But it only seems to display the comments and never do they bit if comments != true

  10. teccus
    Member
    Posted 8 years ago #

    I'm an idiot. &comments=true..

    Works now, cheers for the help matey.

  11. maerk
    Member
    Posted 8 years ago #

    Tada! Glad you got things working :D

  12. teccus
    Member
    Posted 8 years ago #

    Hey again. I got one working, just wanted to try out your other method:

    <?php if ( strpos ($_SERVER['REQUEST_URI'], "comments-only") : ?>
    <!-- don't show posts -->
    <?php else : ?>
    <!-- Do show posts! -->
    <?php endif; ?>

    When I use this, either way it displays nothing, source-code is empty in the browser.. Any ideas?

  13. maerk
    Member
    Posted 8 years ago #

    I'm afraid I don't... How are you using the code, exactly.

    If there is lots of code, pastebin is probably the best idea :D

  14. teccus
    Member
    Posted 8 years ago #

    I've basically just set out a demo like below:

    <?php if ( strpos ($_SERVER['REQUEST_URI'], "comments-only") : ?>
    <!-- don't show posts -->
    <h1>not showing posts</h1>
    <?php else : ?>
    <!-- Do show posts! -->
    <h1>ooo a post</h1>
    <?php endif; ?>

    And in the url it goes:

    http://www.mysite.com/index.php/test-post-here/comments-only/

  15. maerk
    Member
    Posted 8 years ago #

    It's possible that the comments-only bit (and everything after the index.php, actually) isn't condsidered part of the Request URL. Try doing this to see what actually is:

    <?php echo $_SERVER['REQUEST_URI']; ?>

  16. maerk
    Member
    Posted 8 years ago #

    Hmm, I just tried that and it is considered part of the request URL. It looks like it might conflict with wordpress, then. WordPress might be trying to deal with this comments-only thing it finds, but can't, but I'm not sure.

    Post the contents of your page.php file to pastebin.com, and then give me the link to it, I'll take a look to see if there's anything specifically that's going on.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags