WordPress plugin include html

Include Me

Include Me is a powerful plugin that lets you to include in any post or page and external HTML or PHP file or the content of another post/page. When you include a PHP files, they will be executed and their output included, so you can develop independent scripts that can be made available on posts or pages.

An example? You want to publish a report generated by some queries on a database. Just develop such script and make it to output an HTML fragment. Then include it on a page with Include Me.

Example two. You want a dedicated page with your Facebook Fan Page widget (which is made of Javascript). Just create a textual file with Facebook widget code and include it with Include Me.

Where is the advantage over developing a theme custom page? Let me answer with another question: what happens to theme custom pages when you change theme?

Download and Support

Download it here and post your issue here.

Include Me syntax

In any post or page you can use Include Me with the shortcode:

where the “file” attribute contains the filename to be included. Any textual file can be included and if it is a PHP file (with “.php” extension) it will be executed and its output included.

The filename can be relative (not starting with “/”) so it will be searched starting from the blog root folder (for technicians, ABSPATH will be added at the beginning). If the filename is absolute (starting with “/”) it will be used as is (so you can include files even external of the site root folder).

Including another post content

It’s a rather particular case but you may need to include another post content in a series of other posts or pages just to have a single change point. In this case the syntax is:

[includeme post_id=»a post id»]
Читайте также:  Centering heading in html

The “post id” is the nmeric identifier of a post.

Generating an iframe

A second syntax is available and generate an iframe instead to include the file. The iframe syntax is:

where “url” is a common web address. Any other attribute added to the short tag will be used as an iframe attribute. For example if you write:

[includeme src=»http://www.example.com/» frameborder=»0″ width=»500″ height=»400″]

I widely used this plugin (and its old and incompatible version Include It) on my blogs.

Passing variables

If you include a PHP script, it can access the shortcode attributes using the syntax $attrs[‘attribute name’]. For example calling:

[includeme file=»out.php» value=»My name is Stefano»]

The output will be, of course “My name is Stefano”. So you can create a generic script and make it doing different things using the shortcode attributes.

Источник

How to include a html file in wordpress plugin-wordpress

I know this question is old, but for anyone who may come across this, I’m pretty sure the error was the path starting with a backslash, which in Linux would have him pathing from the root directory (/) I assume.

This worked for me. The problem it that the plugin folder need to be added to the url of the file.

function my_function($content) < // all Plugins directory url // Need to add the directory of your plugin $pluginUrl = plugin_dir_url('/index.html', __FILE__); $content .= ' 


'; // Return the content return $content; > // Hook our function to WordPress the_content filter add_filter('the_content', 'my_function');

Ahmed 130

function displayHTMLpage() < $asubHTML = file_get_contents(plugins_url('/myfile/test.php',__FILE__ )); echo $asubHTML; >add_action('wp_enqueue_scripts', 'adsense_unblock_divs'); 

More Answer

  • How to include a html file in wordpress plugin
  • How to include custom php file inside wordpress plugin directory?
  • How to include bootstrap in WordPress plugin development?
  • How to include html tags within a wordpress excerpt?
  • How to auto-generate POT file from a WordPress plugin PHP file?
  • How do I create a zip file installer containing WordPress plugin files?
  • Include a php file in another php file wordpress plugin
  • How to include a file in shortcode function in wordpress
  • How to Include «onclick» Object in WordPress HTML
  • How to correctly make a WordPress plugin returns a downloadable excel file
  • How to upload separate HTML file to wordpress site via FTP client?
  • how to Include json manifest file in wordpress theme
  • How can I include a PHP file in WordPress that is outside of my theme but on the same server?
  • How do I include a javascript file in WordPress admin Widgets
  • WordPress all theme plugin js file is adding this script how can i remove that
  • How to Include WordPress Header and Footer in non-WordPress php file
  • How to add own javascript/css file to wordpress plugin menu page?
  • How to include WordPress plugin changes and related db migrations in git?
  • how to require file from plugin directory of wordpress in theme page
  • How to include PHP file in WordPress that is outside the WordPress Environment
  • How to link the style.css file while converting HTML template to wordpress theme
  • How to delete folder or file in WordPress plugin
  • how to include a css file in a wordpress template
  • WordPress plugin development — File upload: How to allow specified file types?
  • How to edit wordpress plugin .php file
  • How to delete a file from WordPress plugin folder
  • How to Move file in wordpress on plugin activation
  • How do I access a file in a directory from html in a WordPress Site?
  • How to override wordpress plugin template file that is not in «templates» folder?
  • How to include WordPress Advance Custom Field plugin functions in single PHP file?

More answer with same ag

  • Simple wordpress ajax query is not working
  • How to stop all YouTube videos when changing option in select list
  • Random testimonials with images
  • WordPress plugins only loading after page refresh
  • can a social networking site using wordpress CMS handle millions of users?
  • How do I use wp_dropdown_pages in WordPress to show only certain pages?
  • How to get current post type in functions.php in order to use globally?
  • Get daily orders count in Woocommerce
  • How can I add CSS to a PHP script?
  • Converting a .asp form that sends email to WordPress
  • PHP Included File Breaking Site — How can I grab a variable from the included file without including the whole script to my site?
  • List of articles specific to some page
  • Reverse menu order in wordpress
  • WordPress: Match custom field to page title and display related posts
  • Composer fails for private Gitlab Repository
  • htaccess help in coexisting Codeigniter and WordPress install
  • Trying to add a preloaded animation and mouse effect on WordPress
  • I am using Custom fields plugin but I do not see Repeater field in that
  • Google results for my new WordPress site are showing code for a slider
  • comment_reply_link not working in wordpress
  • Need to make WordPress Form Submission trigger a process that registers New User on other Site
  • WordPress Query_Posts Combine
  • Converting Div To Dropdown (with data-value)
  • Assigning & Using unique WordPress post IDs for a script on the main index page
  • Prevent easy downloading of mp3s that play on mp3 players?
  • Issue on Accessing To Ajax Enqeued File to Pass to URL for Ajax Call
  • Is it possible to build a small user login website with wordpress?
  • How to load visual composer during using ajax in wordpress
  • Timber::render does not appear to work correctly on kinsta
  • WordPress — How to avoid adsense ads when viewing thru android App

Источник

Оцените статью