[Support request] PHP Warning: include(): Failed opening

Home Forums Support [Support request] PHP Warning: include(): Failed opening

Home Forums Support PHP Warning: include(): Failed opening

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #757167
    Georgi

    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

    #757171
    Tom
    Lead Developer
    Lead Developer

    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.

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