Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:12:17+00:00 2026-06-18T15:12:17+00:00

I have included header.php and index.php on the same page. The following can be

  • 0

I have included header.php and index.php on the same page.

The following can be found on the header.php file:

<?php 
    $pageName="home";
    if(is_page('47')){
       $pageName="services";}
    printVar($pageName);
?>

function printVar($v){ //on functions.php
    echo $v;
}

It prints out the var immediately after the if-statement and anywhere on header.php, but when I go to index.php it doesn’t print.

<ul class="<?php printVar($pageName); //does not print out ?>">  
    <li class="home"><a href="/">Home</a></li>
    <li class="services"><a href="/">Services</a></li>
    <li class="seminar"><a href="#">Seminar</a></li>
    <li class="contact last"><a href="#">Contact</a></li>
</ul>

How can I print this variable without moving everything to index.php?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:12:19+00:00Added an answer on June 18, 2026 at 3:12 pm

    you need to have

    <?php get_header(); ?>
    

    in your index.php file

    read more about get_header() on wordpress function reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an included php page into index.html. <?php include inc/header.php;?> Dreamveawer cs5 is
I have my index.php page and just afrer my header i want to include
I've got the following directory-file structure; /index.php /head.inc (upper) /subdir/page.php /subdir/head.inc (lower) In /subdir/page.php
I have a site where the pages have the following structure: <?php include('header.php'); ?>
Can anyone please tell why this error? I have included everything ( all header,
I have a file called header.html and it is included by base.html . In
I have a header file, lets say Common.h, that is included in all of
I have an index.php page in which, there is a login form. Index.php: <?php
Here's the scenario, I have a main.js file in abc.com which does $.post(index.php) to
I am fairly new to php but I have an index file in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.