Archived topic
Social links and co-authors in author box
24 replies · Started by Álvaro on November 15, 2020
Hi there,
Code 1 - is a PHP Snippet - this article explains how to add that to the site:
https://docs.generatepress.com/article/adding-php/
Code 2 - needs to be added using a Hook element:
https://docs.generatepress.com/article/hooks-element-overview/
Hi David,
Thanks for the reply.
What are the setting for the Hook element? Please see the screenshot for the options I am referring to: https://ibb.co/0mYmjRL
Looking forward to your feedback.
Regards,
Stefan
Hi David,
1) I tried to add the code (1). See https://prnt.sc/wjwzv4 but it gave me an error (see screenshot of the error: https://prnt.sc/wjx0hy). This is regarding PHP snippet part.
Is there a change in the code that I need to do?
What are the setting for the Hook element? Please see the screenshot for the options I am referring to: https://ibb.co/0mYmjRL
It depends on where you are trying to add the author box. See the visual guide here:
https://docs.generatepress.com/article/hooks-visual-guide/#single-post
generate_after_entry_content hook is a common choice.
I tried to add the code (1). See https://prnt.sc/wjwzv4 but it gave me an error (see screenshot of the error: https://prnt.sc/wjx0hy). This is regarding PHP snippet part.
The code is missing a closing } at the end.
Hi Leo,
Thank you for the feedback.
I added two co-authors for the following blog post (see link: https://www.lifestyledemocracy.com/how-is-the-revolution-will-not-be-televised-poem-relevant-today-2-2/), but it does not display the code that is supposed to go in the PHP, it displays it as text.
Please see the screenshot.
https://prnt.sc/wkad0w
Is there anything that I can do to fix it so both co-author boxes will be displayed?
Regards,
Stefan
Did you check the execute PHP box in the hook element?
Hi Leo,
Yes, I did. I get the same result (see screenshot: https://prnt.sc/wkl9z0). Now, I get both names in the same box, but cannot generate the additional author boxes.
At the moment, I have two separate Hook Elements. Maybe this is the issue.
See screenshot here:
https://prnt.sc/wkl6c4
This is hook element #1:
https://prnt.sc/wkl6ly
This is hook element #2:
https://prnt.sc/wkl6tu
It seemed to work for Alvaro. I don't know why it does not like me :(
Hope you can help :) Thank you for your support.
Hi,
This is hook element #2:
https://prnt.sc/wkl6tu
This hook has broken syntax.
You have to replace { and } with the proper PHP tags <?php and ?>.
Try this instead:
<?php
if( function_exists('coauthors_posts_links') ) {
coauthors_posts_links();
} else{
the_author_posts_link();
} ?>
Hi Elvin,
Thank you for the feedback and for the wise advice :)
I entered the updated code (now, it works, thank you very much). I also cleared the cache when trying each of the changes :)
However, the second author box is still not displayed. https://prnt.sc/wkt82v
Just for the records, I am only using the plugin "Co Authors Plus."
Do you know how to make both author boxes be displayed?
Regards,
Stefan
The original topic poster ending up using another set of plugins to achieve that... he mentions which one here:
https://generatepress.com/forums/topic/social-links-and-co-authors-in-author-box/#post-1533824