Greeting. I work in Wordpress on one project and I need help. What is it about? I made the file data.php where certain data is generated. Now I have to access that file, take variables, and print their values in the title and body of the post. I succeeded to print the post to the post body using the following code line <?php require "data.php"; echo $vrbody; ?> Code (markup): That does not work in the title. I think the problem is in the require function, because this line in title works <?php echo $vrtitle='Some title'; ?> Code (markup): I've tried in the header.php theme file use require function <?php require "data.php" ?> Code (markup): then put following line in the post title <?php echo $vrtitle; ?> Code (markup): but failed. I've been trying to load at few more places desired file (functions.php, wp-config.php), but it has also failed. Can I somewhere load my file so that I can access variables in post title without reloading file? Thanks for help. Sorry for bad English.
May I ask WHY you're doing this? I mean... unless all your posts are the same post, I'm guessing you don't need the same information for every one. Then why create this "data.php"-file? Can't you just utilize the database as it should be utilized? And IF you need the same information on ALL posts... then why not just add it to the single.php-file in the themes folder?
We actually scraping data from other our sites, do some calculations and generate reports. Idea is one report one post so we need collect post title and post body from that file.
Then why don't you create something that inputs the information into the database, making it part of normal WordPress posts, making it easily searchable and so on?
Good idea. Thanks. We are going to try both ways solve problem. I hope boss and rest od team will agree.