Skip to content

Instantly share code, notes, and snippets.

@KevinGimbel
Created December 4, 2013 13:44
Show Gist options
  • Save KevinGimbel/7787601 to your computer and use it in GitHub Desktop.
Save KevinGimbel/7787601 to your computer and use it in GitHub Desktop.
A small but useful function the include the content of a Page into whatever you want - can be used for dynamic contents. Example: You have a mixed language WordPress system where a few repeating texts need to be in English or German depending on whatever criteria. See usage.php for an example. The Path in this case is simply the Permalink or Slu…
// Add this to your functions.php
function include_page_content($path) {
$post = get_page_by_path($path);
$content = apply_filters('the_content', $post->post_content);
echo $content;
}
<?php get_header(); ?>
<section class="content" role="main">
<hgroup class="intro--text">
<?php
// check for the language
if(whatever == "English") {
// if it's english include the text from the english page
include_page_content("my-page-with-english-text");
} else {
// if not, include german
include_page_content("my-page-with-german-text");
}
?>
</hgroup>
<!-- other page content -->
</section>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment