[Resolved] Automatically configure “Add a comment” with the post’s permalink?

Home Forums Support [Resolved] Automatically configure “Add a comment” with the post’s permalink?

Home Forums Support Automatically configure “Add a comment” with the post’s permalink?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1621393
    Edgar

    Hi…

    I just started using GP last week for my blog, and I wanted a more conspicuous way for readers to add a comment after reading each post. So I added as the last line of the post, the following HTML link:

    <p style="text-align:right"><a href=”https://www.mouseprint.org/2021/01/11/godaddy-offers-employees/#respond">Leave a comment</a></p>

    Which renders like this at the bottom right of the post:

    leave a comment

    (My permalinks are of this style: https://www.mouseprint.org/2021/01/11/godaddy-offers-employees/ )

    Rather than have to add this line manually to each post, and embed the new permalink each time in the HTML, is there some automated way to have this “add a comment” link added to each post as the last line?

    Thanks,
    Edgar

    #1621624
    Leo
    Staff
    Customer Support

    Hi there,

    You can try using a hook element:
    https://docs.generatepress.com/article/hooks-element-overview/

    The hook you are after should be generate_after_entry_content.

    Let me know if this helps 🙂

    #1621631
    Edgar

    Hi Leo…

    I am a newbie, so I need more hand-holding and specific code. I have created hooks, but you need to tell which of the several varieties and options to choose. And I need the explicit code to enter there.

    Hope you can help.

    Thanks,

    Edgar

    #1621837
    Leo
    Staff
    Customer Support

    – Create a new Hook element.

    – Add this as content:
    <a href="#respond">Leave a comment</a>

    – Choose generate_after_entry_content under the Hook.

    – Go to display rules and select Post > All Posts.

    #1622145
    Edgar

    Hi Leo…

    Unfortunately that did not work.

    Under Elements, add new element, I followed your instructions, but nothing new was displayed on existing posts on the website.

    I even tried variations like “../#respond” and “/#respond” with no success.

    Can I propose an easier solution to my problem? GP automatically puts a comment link and count at the end of each post. I used some custom CSS to move it to the right and make it slightly larger. What I am not able to do is make the font blue like all the other links using this code:

    .comments-link {
    	  font-size: 22px;
    	  text-align: right;
    	  color: blue;
    	  text-decoration: underline
    	}

    Can you suggest a way to make the font blue?

    Thanks,
    Edgar

    #1622660
    Leo
    Staff
    Customer Support

    Hmm my solution should work.

    I actually tested it as seen here:
    https://www.screencast.com/t/D4UyRGZi

    Can you make sure you did the same thing?

    If this still doesn’t work then please link me to the page in question.

    #1622679
    Edgar

    Hi Leo…

    It absolutely did not work. In your demo, I think you may be just duplicating the already built-in “add a comment” feature and what you are seeing is the automatically generated one. If you change the wording of your hook, I don’t think you’ll see it come up anywhere.

    In any event, I finally just figured out how to use that build-in add a comment by adding the following custom CSS:

    .comments-link {
    	  font-size: 22px;
    	  text-align: right;
    	  color: #3274C0;
    	
    }
    	
    a:link {
    				color: #3274C0;
    	}	
    
    a:visited {
    				color: #3274C0;

    I don’t want to go back and undo everything to demonstrate how the code you provided did not work. I appreciate all your efforts.

    Edgar

    #1622690
    Edgar

    Leo…

    Just as a demonstration, I just undid my changes and used your code instead… but I called the link “Don’t leave a comment”.

    I activated it, and you will see that that new link did not appear anywhere.

    See screen capture. This will download rather than display.

    Hope this helps.

    Edgar

    #1622896
    Leo
    Staff
    Customer Support

    If you change the wording of your hook, I don’t think you’ll see it come up anywhere.

    The text can be whatever you want, the important part is the link which takes you to the reply section.

    I thought that’s what you wanted but maybe I misunderstood.

    Glad you found a solution for your need.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.