I need php code to create a static front page for my blog.how do it by php in wordpress.anybody can help me.
|
|
From @Ray Mitchel's answer the tutorial shows you how to set a specific page in your blog to be the front page. Assuming you're using the TwentyEleven theme, you need to learn about page templates. The WordPress site has an article: http://codex.wordpress.org/Pages#Page_Templates. So you can create a page template by starting by copying the home.php file and renaming it to my-page.php and put the following at the top of the page:
Once you have saved the file, in any page you can switch the page template, and in the drop down you should now be able to select 'Snarfer'.
Now the correct name for the front page is front-page.php. If you call your file that, the page that you have set to be the front page will automatically use the front-page.php file without you having to set the page template. Even further to this once you've named your file front-page.php you don't have to bother setting a specific page to be the front page as the front-page.php file will get called instead of home.php (the standard home page). Below you can see why, which is thanks to the WordPress Template Hierarchy the front-page.php file comes above the home.php file if you leave it to display posts on the front page (which is the default):
|
|||
|
|
|
In your theme directory you can add or modify your front-page.php file et code in whatever you want. |
|||||
|
|
Is this for a theme you are developing, or are you using an existing theme? Quoting from the WordPress codex "Creating a virtual static front page does not require editing or coding of files or templates." In most cases, you can have a static front page by changing the settings in the administration area. Here is the link to that section http://codex.wordpress.org/Creating_a_Static_Front_Page |
|||
|
|
|
You don't have to make any template or other programmatic changes just to use a static Page as your site front page:
That's all you need to do. Your site now displays a static Page as the front page. |
|||
|
|
|
There are a few right answers to your question. It just depends on how custom you want that home page. What I do is create a home.php file and start with what is contained in my page.php in my theme. Then, I customize it the way I want. If the theme has a home.php file, it uses it for your home page. For most of my sites I like to start with a slider of some kind, then have maybe three "action" boxes with a photo, headline, link and some text. I accomplish this with a custom post type. Some times I may want to list some of my posts in a small box, sometimes I would like a sidebar, others not. The point is that I can customize my home page just by customizing this home.php. I will give you one of my standard home.php files below and you can dissect it to see how I use it.
|
|||||
|
|
For that you have to create one PHP file is known as page template in wordpress. page template always start with :
After that you have to write all other code in page template. after creating page template file, create one page and switch on page attributes box in this box one drop down list with the name template and select your page template after that publish your page. for create a static front page read this http://codesmeister.blogspot.in/2011/10/how-to-make-homepage-front-page-in.html |
|||
|
|


