The first line of index.php is get_header();
There is no include / require in my index.php. yet the wordpress site continues to render the head section of home page by referring get_header() from general-template.php
How is wordpress framework achieving this?
get_header() is a function located in wp-includes/general-template.php.
This function includes the header.php template file from your current theme's directory.
If your theme contains no header.php file then this function includes the header file located in wp-includes/theme-compat/header.php.
You can find more information about this function in codex of Wordpress.org
The index.php you're referring to is the index off your theme. Within the root folder of your WP installation also an index.php is located. This is the first one called and starts the whole 'trip'.
http://theme.fm/wp-content/uploads/2011/09/wordpress-internals-how-wordpress-boots-up-382x600.png shows an image of the complete file load-sequence.
Related
I have two side-menus on my Wordpress site that I have saved as php files. I am able to call these into my page.php file with the the following line of PHP <?php include("mobile-menu.php"); ?>
For some reason, I am unable to do the same in another of my page templates in a sub-folder. My template structure is fairly simple, in my main theme folder I have header.php, footer.php, mobile-menu.php etc. Then in a sub folder called "page-templates", I have another template called full-page.php. This is the template in which I am having trouble calling mobile-menu.php with the include function.
I have tried the following:
<?php include("../mobile-menu.php"); ?>
<?php include(__DIR__."../mobile-menu.php"); ?>
When I use get_header(); in index.php, it automatically load the header.php file and and need not to include anything in the page.
Generally index.php is the main page. everything should be include there before it was called. Am I wrong?
It seems you are checking index.php inside the theme. But that is not the entry point to the site, but the index.php file in the wordpress root. There you can see it has included some files and inside those they have included some other files. Like wise file including functions are written in the wordpress core codes. So, you don't want to worry about including files in your theme. if you call get_header() function, the function itself has coded so that the relevant file to be included. If you are going to use a separate file to code functionality other than standard wordpress theme files, you'll have to include it at the top of functions.php
I am having some issue with site I am developing. Let me know you some of the pages are static php pages which are working fine. But the issue is with wordpress pages, I have all css and js files are included from header-required.php file. I am calling this header-required.php file from function file by wp_head hook. here is my code of function.php file:
function hook_javascript()
{
include('http://'.$_SERVER['HTTP_HOST'].'/inc/header-required.php');
}
add_action('wp_head','hook_javascript');
And I am calling this function from all wordpress file code wp_head();
here is the code:
while loading, This function is calling properly, but it does not including file header-required.php. If i am including this file from specific wordpress file, Its working.
Please help. Thanks..
your specified path is correct. Actully I am calling this file from wordpress and header-required.php file is php file which is outside wordpress directory. example.com contain all static php pages, and inside this directory,I have created one another directory called wrpas, which contains wordpress. This some what confusing because i am using static php pages and wordpress together on one site. Another thing header and footer files are static php pages, which i am using in wordpres.
Thanks!!!
Put that file in theme folder
Rather than using php include use get_template_part for wordpress
Use
<?php get_template_part('header-required'); ?>
For more details
http://codex.wordpress.org/Function_Reference/get_template_part
Don't include through hook because this is php file, you can directly include through include and require function in your header.php file inside the theme.
I'm using <a href="<?php the_permalink();?>" Take me to another page </a> to take the user to a permalink page.
However, when I do, it is saying No input file specified.
I have the following files in theme folder:
footer.php
functions.php
header.php
style.css
index.php
How come this is not working — am I missing another php template file?
Your template files have to be in a directory under /wp-content/thmes/your-theme/. After you inserted them into the theme dir you have to activate your theme in the wordpress administration.
You need also at least a index.php File. That's the file where you place the functions for your content. In the index.php your include the header.php and footer.php with the Wordpress functions get_header() and get_footer().
I think you should better read the Documentations:
http://codex.wordpress.org/Using_Themes
http://codex.wordpress.org/Theme_Development
I want to distribute my page contents in various files for a wordpress theme. As I can do with header, sidebar and footer.
Something like
<?php get_imageslidercontent(); ?>
or anything else.
You should put this function in the functions.php file that is in your theme root folder and then you can use your function in your theme