WordPress.org

Forums

Add content from external PHP file to post content (1 post)

  1. cvilela
    Member
    Posted 1 year ago #

    Hi,

    I'm trying to create a plugin that will add the content of an external HTML or PHP file (in this file I would have javascript and an html form)

    Here's what I first tried

    function clientrelation_add_before_content($content) {
    
     $output .= "<div class='my_div'>";
     $output .= "<h4>Hello World!</h4>";
     $output .= "</div>";
     $output.= include( plugin_dir_path( __FILE__ ) . 'client-relation/entonnoir.php');;
    
     $output .= $content;
    
     return $output;
    }

    When I refresh a post, I get the following error:

    Warning: include(/home/content/my_site/wp-content/plugins/client-relation/client-relation/entonnoir.php) [function.include]: failed to open stream: No such file or directory in /home/content/my_site/wp-content/plugins/client-relation/client-relation.php on line 93
    
    Warning: include() [function.include]: Failed opening '/home/content/my_site/wp-content/plugins/client-relation/client-relation/entonnoir.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/content/my_site/wp-content/plugins/client-relation/client-relation.php on line 93

    There must be a way to do this?

    Thanks guys
    Chris

Topic Closed

This topic has been closed to new replies.

About this Topic