• Hello..
    I am using WP 4.7.2 with Twenty Twelve Theme,
    And using “Social Comments” plugin to show Comment form for facebook, G+, Disques and WP comment.

    My homepage shows only last recent added post (only one post)..

    I need to show comment form (as Social Comments plugin shows it) under this post in home page?

    Thank you in advance for help.

    • This topic was modified 7 years, 10 months ago by essamy.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Joey

    (@leglesslizard)

    Hey,

    It looks like you may need to rewrite and call the plugins function “add_socialcomments_tmplate”. By hacking the plugin and adding is_home() in the if statement (line 266) the comments appear on the homepage. Of course hacking the plugin isn’t ideal as this will break when you update so I would look at creating my own version of this function in a custom plugin (relying heavily on the Social Comments plugins code, using their functions wherever possible) and call my custom function from the theme template (with checks in place to make sure the functions exist first!)

    Basically it looks like all you need is to add “is_home()” in the page check before the comments are loaded but this isn’t properly tested.

    Hope that helps some!

    Regards,
    Joey

    Thread Starter essamy

    (@essamy)

    Thank you very much Joey..

    Please..

    1- Where is this function “add_socialcomments_tmplate” and how I can add is_home() in the if statment?

    2- Do you see that I use this solution or search for another one or another plugin?

    Thank you.

    Joey

    (@leglesslizard)

    The function is in “plugins/social-comments/plugin.php” line 264. I adjusted line 267 to read:
    if (( is_home() || is_single() || is_page() || is_singular()) && comments_open()){

    and the comments appeared after the test post I had on the homepage. I don’t have any experience with this plugin but have done many jobs similar to this. This was just a quick “hack” I put in place to see if any obvious issues appeared (which they didn’t) and is not fully tested. You’d have to test this worked as desired and adjust if necessary.

    While this may provide the outcome you wish for it is not ideal as, as stated above, when the plugin is updated it is overwritten with a newer version and any changes made within the plugin itself are lost. To avoid this you would need to create your own plugin, rewrite the function to work in it’s own instance (either simply rename the plugin and apply your change to any updated versions that are released OR write a simple plugin that just overwrites that function and call that in your theme instead). The second option, in my opinion, is the better option but will require some experience with PHP or a willingness to learn some ??

    Another option if you do not have experience with writing code would be to reach out to the developers of the plugin and ask for assistance. They would know the code better than anyone else and perhaps be able to provide a robust solution to your problem. They may even edit the plugin to suit your needs by placing a filter for where the comments can be displayed (people who release open source code are usually very helpful!)

    Good luck!
    Joey

    Thread Starter essamy

    (@essamy)

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to show comment form under recent post on hompage?’ is closed to new replies.