Support » Themes and Templates » Use one variable in two files

Use one variable in two files

  • Hi,

    I use custom fields in my theme to display a custom CSS background image and a custom copyright text for each post. In my HTML source, I call the custom fields in the HTML head (for the CSS part) and below the text of the post (for the copyright text). This works fine on single post pages. On the index page there should be only the custom fields of the first post. I get the information of the last post of the index page instead. It seems like WordPress overwrites the information with each post.

    If I could get all the custom field information with a PHP variable at the HTML head (header.php) and use that information/variable in other theme files (e.g. post.php or index.php), this would help me a lot. Doesn’t work though. Any advice?

  • The topic ‘Use one variable in two files’ is closed to new replies.