WordPress.org

Ready to get started?Download WordPress

Forums

Use one variable in two files (1 post)

  1. Gregormo
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic