Just started learning PHP and Wordpress.

Why isn't my PHP include statement working in the following header.php file?

<!DOCTYPE html>
<meta charset="<?php bloginfo('charset'); ?>" />
<?php include 'functions.php';?>
<?php if( is_page(1406)): ?>
<?php wp_title(' - ', true, 'right'); ?> <?php get_1406_page_title(); ?>
<?php else: ?>
<?php wp_title(' - ', true, 'right'); ?> <?php bloginfo('name'); ?>
<?php endif; ?> 

I need to call get_1406_page_title() which is located in the functions.php. The above code produces empty page, and when I remove the include line the title is empty.

Here is the get_1406_page_title() from functions.php:

function get_1406_page_title()
    $title = "Page title here";
    return $title;
  • 2
    You do not need to include your theme's function.php - it is loaded automatically.
    – fischi
    Commented Feb 26, 2016 at 9:21
  • OK, thanks. So I should look for the problem elsewhere, maybe my get_1406_page_title().
    – Danijel
    Commented Feb 26, 2016 at 9:24
  • 3
    Enable the debug mode to find the real reason.
    – fuxia
    Commented Feb 26, 2016 at 9:30
  • You do not need wp_title(), it is a supported theme option Commented Feb 26, 2016 at 9:33
  • Updated questions with get_1406_page_title() source.
    – Danijel
    Commented Feb 26, 2016 at 9:41

1 Answer 1


From your current code you

  • do not need to include functions.php, it is automatically done

  • Because get_1406_page_title() returns it's output, you need to echo the result from the function if you need to display the result

    echo get_1406_page_title();
  • Thanks so much. How come bloginfo('name'); doesn't require echo? It also returns a string.
    – Danijel
    Commented Feb 26, 2016 at 9:47
  • No, bloginfo() echos output, check the source. I think you are thinking about get_bloginfo() Commented Feb 26, 2016 at 9:50
  • Ah OK... got it. I will do the same, wrap get_1406_page_title() into 1406_title() with just additional echo to make is cleaner. Thanks.
    – Danijel
    Commented Feb 26, 2016 at 10:02
  • Great idea. Good luck with your project. Enjoy ;-) Commented Feb 26, 2016 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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