{"id":77194,"date":"2014-04-29T16:17:17","date_gmt":"2014-04-29T20:17:17","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=77194"},"modified":"2014-04-29T16:17:17","modified_gmt":"2014-04-29T20:17:17","slug":"include-content","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/services\/cccs\/websites\/www\/wordpress\/how-to\/include-content\/","title":{"rendered":"Include content from a page\/post or media file on another page"},"content":{"rendered":"<h2>BU Include Plugin<\/h2>\n<p>Use the BU Include plugin to embed the content of a page, post, text file or HTML file into another page or post on your site.\u00a0 For example, if you have a page that lists office hours and contact information, you can use BU Include to embed this information on any other page on your site.\u00a0 Should your office hours change in the future, you only need to update a single page and the rest are updated automatically.<\/p>\n<h2>Usage<\/h2>\n<h4>Including a page or post<\/h4>\n<p>Pages and posts must be included by their ID.\u00a0 The following example would be used to include a post with an ID of 500.<\/p>\n<p><em>Include by ID<\/em><br \/>\n<code>[bu-include id=\"500\"]<\/code><\/p>\n<h4>Including media<\/h4>\n<p>You may include any media that is present in your content directory as long as the filename ends in .txt or .html.\u00a0 Media may be included by ID or by its location relative to your blog&#8217;s\u00a0<code>files<\/code> directory.\u00a0 The latter form can be useful when you have files in your content directory that, for one reason or another, do not exist in the media library.<\/p>\n<p>When including a file by name, you may use a fully qualified URL as long as it points to your blog&#8217;s content area.\u00a0 A simpler alternative is to provide a path to the file relative to your blog&#8217;s content area.\u00a0 The former offers no advantage over the latter.<\/p>\n<p><em>Include by path<\/em><br \/>\n<code>[bu-include src=\"2010\/06\/foobar.txt\"]<br \/>\n<\/code><code>[bu-include src=\"http:\/\/www.bu.edu\/myblog\/files\/2010\/06\/foobar.txt\"]<\/code><\/p>\n<h2>Recursion<\/h2>\n<p>Recursion is respected. That is, if the included content contains [bu-include &#8230;] as well, that will be parsed. However, if a loop is detected (A includes B includes A), the shortcode where the loop occurs is disregarded and left blank. That is, if A includes B includes A, and you view A, then you will see A, with B embedded in it, but A will not be embedded into B again.\u00a0 By following the same rule, if a page includes itself then nothing will happen and the include is ignored.<\/p>\n<p>For example, consider the following:<\/p>\n<p><strong>Page A, ID = 500<\/strong><br \/>\n<code>This is page A.<\/code><br \/>\n<code>[bu-include id=\"501\"]<\/code><\/p>\n<p><strong>Page B, ID = 501<\/strong><br \/>\n<code>This is page B.<\/code><br \/>\n<code>[bu-include id=\"500\"]<\/code><\/p>\n<p>If you were to then view\u00a0<strong>Page A<\/strong>, this is roughly what you would see:<\/p>\n<p><code>This is page A.<\/code><br \/>\n<code>This is page B.<\/code><\/p>\n<p>Page A is not shown more than once due to recursion protection.<\/p>\n<h3>Caching<\/h3>\n<p>When a post, attachment, or page is updated, any pages which include it have their cache purged.\u00a0 These pages are identified by first sweeping the database for posts with &#8220;bu-include&#8221; in their content, and then by looking into each to determine if it includes the post that was updated.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BU Include Plugin Use the BU Include plugin to embed the content of a page, post, text file or HTML file into another page or post on your site.\u00a0 For example, if you have a page that lists office hours and contact information, you can use BU Include to embed this information on any other&#8230;<\/p>\n","protected":false},"author":1303,"featured_media":0,"parent":304,"menu_order":31,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/77194"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/1303"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=77194"}],"version-history":[{"count":1,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/77194\/revisions"}],"predecessor-version":[{"id":77195,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/77194\/revisions\/77195"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/304"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=77194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}