How to link to index.php from static page in wordpress? - wordpress

In my wordpress template I design an intro page and set it as static page, Now in it I want put a button that when user click on it index.php's content would be shown.

index.php is the default template used through Wordpress.
See https://codex.wordpress.org/Template_Hierarchy
Just create another page and ensure the page template used is 'Default Template' and link to this page where required. The index.php template should be used by default.
If you have a page.php template, this will override index.php. So in this case duplicate the index.php file, rename to something like page-custom.php and add the following code to the first line of the template file.
<?php
/*
Template name: Custom Page
*/
?>
Now from the 'Page Attributes > Template' drop-down in Page Editor you will see your 'Custom Page' template in the drop-down list

Related

how to move the physical location of the permalink header in wordpress?

Does anyone know how to move the physical location of a permalink header in wordpress? I dont want it to be the first thing that is seen but rather I want a shortcode item there.
In your page.php you can delete the php function for calling the header ( the_header() ) and put the function to call the shortcode ( do_shortcode() ).
This way the page is not embeding the header.php but get the code of your shortcode at this place of your markup.
Page Template:
You can create a page template in your theme-folder. For this, you can simple duplicate the page.php and call it page-yourname.php. At the top of your page you add the name of the page template:
<?php /* Template Name: Example Template */ ?>
In that file you do the adjustments that you like to do with the shortcode.
https://developer.wordpress.org/themes/template-files-section/page-template-files/
With the template structure of wordpress, the template will automatically be found at the edit screen of your pages. It will be found on the right side under "page attributes".
You can set the template for your individual pages. So your adjustments to the template will only affect your pages, where you selected the template in the page attributes.

how to create static front page without using index.php

WordPress:
I am trying to create a Static Home Page without using index.php
I have created a post page using index.php
I have created a front-page.php for the Home-Page.
I go to Setting>Reading>Front page: Home and then again
Setting>Reading>Posts page: (Name of Post page)
My Problem: Front-page showing "PostPage"
How to solve this issue?
You should create a template name for your front-page.php.
Add this lines before the get_header();
<?php
/*
Template Name: homepage(or everything you want)
*/
?>
After that go to pages on wordpress and add to the page you want to set as frontpage the template homepage(or everything you want).
Go to Setting>Reading>Front page and set the page which has the template as front page.
I found this answer. I made a copy of index.php and renamed it home.php. And its working nice!

Wordpress custom folder as homepage

In my wordpress I have a folder name custom which is a custom script. I visit myexample.com/custom the script does work. But I wish to use myexample.com for the script instead of myexample.com/custom. I want to replace the custom script rather than displaying the default homepage of wordpress.
Just add template comments in top of you main file under the custom folder.
<?php /* Template Name: Example Template */ ?>
How to create page template: http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress/
Create a new page select this page template from page template dropdown and set this page as home page.

Wordpress: create a custom home page

I want to create a website using wordpress, but I want my website to have a customized home page, created by me, completely different from the theme of the site, and then link the wordpress pages directly from my page.
Is this possible? How can I achieve this?
Can I simply create the page, and link the other created with the wordpress panel, without breaking everything?
According to official WordPress codex:
If a visitor goes to your home page at http://example.com/blog/, the following happens:
WordPress first determines whether it has a static front page. If a static front page has been set, then WordPress loads that page according to the page template hierarchy.
If a static front page has not been set, then WordPress looks for a template file called home.php and uses it to generate the requested page.
If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page.
Therefore you just need to create a home.php template and place it with the other theme (which so ever theme you will use) templates and WordPress will automatically start using home.php template for the home page.
Just copy the default page.php template file and call it front-page.php. Change the configuration at the top of that file. Now create a new page called home.
Go to Administration > Settings > Reading panel and set a static front page.
For more help check this link on the Wordpress website:
https://codex.wordpress.org/Creating_a_Static_Front_Page
If you create HTML off your home page first than this is easy for you
First Create a file Like this "template-home.php" in your theme.
Now in "template-home.php" First you must write these lines at the top of the page
<?php
/* ==========
Template Name: Home
========== */
?>
After that add your header.php and footer.php like this:
<?php get_header(); ?>
// Your Content is here
<?php get_footer(); ?>
Now your Whole HTML is work between in Header and Footer
Then Go to your Admin Panel
Go to Pages > add new
and create a page named "Home"
NOTE: When you create a page Please Select a Template of Home and "Publish" it.
Then go to Settings > Reading and select "A static page (select below)" radio button, then a drop down is active and select your "Home" Page Then click on save changes.
I hope this will help you
You can create a front-page.php file in your active theme folder.
It can be use for both Your latest posts or a static page as you want.

page.php and index.php error in wordpress theme

I have created index.php file and created a page called Home in wordpress admin section. I set the Home page as front page. It works fine.
And i have created page.php file. After creating this page.php file, the created Home page (front page) simply seems blank.
(Note: i did not do any design in page.php file)
My question is, when setting the front page it will call only the index.php. But why after creating page.php, the Home page takes the page.php file. Please help me.
If you have created a page called home and you have selected this page as the home page in the WordPress settings panel, your created 'home' page will assume the template to use is page.php - since it's a page. (check WordPress template hierarchy)
If you want to use the index.php template for your home page, add the following at the top of the index.php file.
<?php /* Template Name: Home */ ?>
Then navigate to that page in the admin panel, and select the template 'home'. Your page now uses the template 'home' which is index.php not page.php - that will sort the problem.
Template hierarchy is correct. To take further advantage of this you can copy and paste your index.php or your page.php code into a new file named home.php. WordPress recognizes this as your default front page (over index and page.php templates) if it exists.
To continue with the way you are attempting, duplicate index.php (or page.php), name this file page-home.php and at the very top add in
<?php /* Template Name: Home */ ?>
Save this to the theme folder. Create a page within the administrations "Page" tab. Make sure to choose the correct template (Home) from the dropdown on the right side of the edit screen.

Resources