Comments on Landing Page

  • PizzaDave

    #18856

    Unfortunately it doesnt work. I also inserted ‘graphene_after_post_content ‘ but no joy there either.

    I did find the following line in the loop.php which seems to point towards home page posting is

    Code:
    <?php if ((is_home() && !$graphene_settings[‘posts_show_excerpt’]) || is_singular() || (!is_singular() && !is_home() && $graphene_settings[‘archive_full_content’])) : ?>

    unfortunately I don’t know what to do with it or how to apply it in the child theme.

    Anonymous

    #18857

    Can you post your child functions.php file here for us?

    PizzaDave

    #18858

    the only thing in there was what you posted above. I changed it to when it didn’t work.

    <?php
    function graphene_force_comment(){
    if ( is_home() ){
    $withcomments = 1; // force comments form and comments to show on front page
    comments_template();
    }
    }
    add_action( 'graphene_after_post_content', 'graphene_force_comment' );
    ?>

    If it matters, I have “full post” checked, not the excerpts. my page is very basic at this point. http://www.chihuahuapictures.net

    Anonymous

    #18859

    I don’t think that matters for this hack.

    Try this one:

    <?php
    function graphene_force_comment(){
    if ( is_home() ){
    global $withcomments;
    $withcomments = true; // force comments form and comments to show on front page
    comments_template();
    }
    }
    add_action( 'graphene_bottom_content', 'graphene_force_comment' );
    ?>
    Admin

    Syahir Hakim

    #18860

    You would have to attach it to the graphene_loop_footer hook which is inside the posts loop, and not the graphene_bottom_content hook which is outside of the posts loop. This is because the comments template need to be run for each post, which requires it to be inside the posts loop. Otherwise it’ll just run once, taking the comment data from the last post being displayed.

    PizzaDave

    #18861

    No, still nothing.

    Is there a way to check the status of $withcomments? Sorry, not familiar with php enough to know the code. My thinking is if the variable isn’t available or being updated, ie, still showing 0 or false, it wouldn’t cause the function to fire.

    TobiF

    #18862

    Hmm.

    Comments are always related to a particular post (or page).

    So, you could either show a list of all the latest comments (globally for the whole site) at the end of the front page, but reusing and expanding the type of code you’ve got in the /latest comments/ widget.

    But if you want to have a comment form… Then there would need to be one comment form for each post!

    And, the easiest way to show comments on the front page would be to show them directly after their respective post, but then the list of comments needs to be within the main loop.

    When you reach the footer, the loop is closed, and no post is active, so you can’t just grab the related comments there.

    So, something like:

    Set a global variable: Number of comments per item to show on front page

    Then, inside the loop: if this variable is greater than 0 and there are comments, then loop through the latest n comments, before the loop continues to the next item.

    PizzaDave

    #18863

    Having the comment form on each post would not be a problem. I could make the form minimal. My main goal with this project is to use uploading the picture for interaction so even just an upload box with a name and short comment box is workable. In fact I want to have the form on each post. I don’t have enough dog pictures to continue posting myself indefinitely. Having others upload their own pictures gives me the content.

    I know this would probably work better with a bb but thats too complicated for what I am trying to do.

    I actually hoped this would be easier to do. Older versions of WordPress had this built in (I think) but removed it because of slower download times. Maybe I should re-think the project.

    Admin

    Syahir Hakim

    #18864

    I just tried this code in a child theme, and it works in placing both the comments and comment form on the front page posts listing:

    <?php
    function graphene_force_comment(){
    if ( is_home() ){
    global $withcomments;
    $withcomments = true; // force comments form and comments to show on front page
    comments_template();
    }
    }
    add_action( 'graphene_loop_footer', 'graphene_force_comment' );
    ?>

    Are you sure you’ve implemented the function and child theme correctly?

    PizzaDave

    #18865

    Eureka! It works. I want to thank all that have contributed to this thread and helped out. It does finally work. The error was entirely mine. I hate to admit it but I named my child functions.php function.php which is why it did not work. Once I changed it, it works fine.

    I should have tested the child theme with something I knew worked but it seemed so simple to just create the file, I did not check it and assumed I had copied it properly. Kind of like trouble shooting a computer that you forgot to plug in.

    Thanks again for the help everyone, especially Josh who stuck with me longer than anyone else.

Viewing 10 posts - 11 through 20 (of 22 total)

  • You must be logged in to reply to this topic.
Graphene Themes Forum