Archived topic
PHP Warning: include(): Failed opening
1 reply · Started by Georgi on December 14, 2018
Hi there,
I am adding social buttons and related posts to my website without plugin and I have an error with the share buttons on my site after I moved to the latest version.
Here is the code I use - it's added to function.php
**
* Social media share buttons
*/
function wcr_share_buttons() {
$url = urlencode(get_the_permalink());
$title = urlencode(html_entity_decode(get_the_title(), ENT_COMPAT, 'UTF-8'));
$media = urlencode(get_the_post_thumbnail_url(get_the_ID(), 'full'));
include( locate_template('share-template.php', false, false) );
}
Here is the error:
Warning: include(): Filename cannot be empty in /home/supple82/public_html/wp-content/themes/generatepress/functions.php on line 151
Warning: include(): Failed opening '' for inclusion (include_path='.:/usr/local/php72/pear') in /home/supple82/public_html/wp-content/themes/generatepress/functions.php on line 151
Hi there,
No changes should be made to core files.
Instead, add your code using a child theme: https://docs.generatepress.com/article/using-child-theme/
Then, make sure share-template.php exists in your child theme folder.