WordPress.org

Forums

[resolved] Template Selection based on Date? (8 posts)

  1. locusta
    Member
    Posted 5 years ago #

    I'm working on a Comicpress site and need to allow readers to comment on the comic and the blog when the posts are on the homepage, but completely hide the comic comments on older comics. I'm thinking of doing this one of two way. Can anyone tell me if either are possible?

    1) Create a separate single.php template (which controls the page you can read/write comments on) based on publish date. Either by setting a specific number of days to swap templates or by somehow stating "published comic post after the most recent comic post".

    2) Moving the commenting function completely to the homepage and then hiding it when some sort of dynamic dropdown.

    Are one or both of these options possible? Is there an easier way?

  2. Frumph
    Member
    Posted 5 years ago #

    Just to ask, have you figured out how to have comments display on the home page to begin with?

  3. locusta
    Member
    Posted 5 years ago #

    Honestly no. Not within the WordPress system, although it seems to me that I should be able to call a comments template to the homepage. That's why I was wondering if this is even possible or what a reasonable work around would be.

  4. locusta
    Member
    Posted 5 years ago #

    Quick update, I did figure out how to get comments to display on the homepage after some more digging on the forums here. The following code will call the comment template:

    <?php  $withcomments = "1";
      comments_template('', true); ?>

    Now I have a bunch of tweaking to try and keep the comments from routing me to the single.php page after leaving a comment. :-/ Which is probably easier said than done...

  5. locusta
    Member
    Posted 5 years ago #

    Ok, I was able to get a redirect back to the index page after commenting by editing the wp-comment-post file (not my favorite thing to messing with but...). So I'm not being redirected to the single.php page anymore. Also commented out the comment template on the single.php pages.

    I am, however, getting a 404 when I try to click through the archive to the most recent page. Could something I did with this comment adjusting have done that or have I screwed something else up?

  6. Frumph
    Member
    Posted 5 years ago #

    .. You probably messed something up when you edit code like that. Why .. pray tell are you so concerned about having the comments on the index page only?, or at all?

    I guess I can understand viewing them.. sure .. but after that page is archived they're gone for good according to your model.

  7. locusta
    Member
    Posted 5 years ago #

    It's by request from my client, but essentially we want readers to be able to comment on the current page, but not be able to comment or see comments on past pages. My understanding is that to comment on an "post", WordPress routes the reader to the single.php page to do the commenting, etc. But that would leave the comic pages in the archive with comments visible on them.

    If there is a more elegant solution, I'd be all for it. Just turning off comments after a set time isn't really sufficient.

  8. locusta
    Member
    Posted 5 years ago #

    I seem to have shaken out the bugs and gotten this to work. Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic