With the following function, the content of another page is included into a page template, which is working fine:

// add content of another page
function show_post($path) {
  $post = get_page_by_path($path);
  $content = apply_filters('the_content', $post->post_content);
  echo $content;

The function is called like this:

Now I placed this code inside a custom taxonomy template:

  • taxonomy-$taxonomy-$term.php

Is there a possibility, to give the $term-name automatically in this function, without hard-coding it?

For example, the custom taxonomy template is taxonomy-cars-mercedes.php, I want the function doing this:

show_post('mercedes');  // Shows the content of the "About" page. 

You can get the current term slug from the global query. You could do something like this:

if( is_tax('cars') ) {
    //We are in "cars" taxonomy archive page, now get the queried term
    $term = get_query_var( 'term' );
  • Glad to help. If it answer your question please, mark the answer as accepted. – cybmeta Jan 11 '15 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.