Created
December 4, 2013 13:44
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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