• teccus

    (@teccus)


    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?

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

    (@maerk)

    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; ?>

    Thread Starter teccus

    (@teccus)

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

    Thread Starter teccus

    (@teccus)

    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?

    maerk

    (@maerk)

    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?

    Thread Starter teccus

    (@teccus)

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

    Thread Starter teccus

    (@teccus)

    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.

    maerk

    (@maerk)

    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

    Thread Starter teccus

    (@teccus)

    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

    Thread Starter teccus

    (@teccus)

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

    Works now, cheers for the help matey.

    maerk

    (@maerk)

    Tada! Glad you got things working 😀

    Thread Starter teccus

    (@teccus)

    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?

    maerk

    (@maerk)

    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 😀

    Thread Starter teccus

    (@teccus)

    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/

    maerk

    (@maerk)

    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']; ?>

    maerk

    (@maerk)

    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.

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

The topic ‘Permalinks and Comments’ is closed to new replies.