customization - How to redirect Wordpress home page to custom static HTML page

admin2025-06-02  1

I am facing an issue while I upload the custom HTML page into my Wordpress site.

The page all alone working fine as I put it in separate folder or if I change its name to index.php . But then their arise a conflict between this custom page and the other WP theme pages .If I set this as a index.php page in theme or root WP .This page runs swiftly but other theme pages doesn’t work .Just show the same index page but with broken css

So all I want is not to broke my theme page as well to set custom html page it as my default Home Page How can I achieve this ? I am using divi them

HTML page that I want to set as my Default Home page :

Rest of site :

I am facing an issue while I upload the custom HTML page into my Wordpress site.

The page all alone working fine as I put it in separate folder or if I change its name to index.php . But then their arise a conflict between this custom page and the other WP theme pages .If I set this as a index.php page in theme or root WP .This page runs swiftly but other theme pages doesn’t work .Just show the same index page but with broken css

So all I want is not to broke my theme page as well to set custom html page it as my default Home Page How can I achieve this ? I am using divi them

HTML page that I want to set as my Default Home page : http://filmyoze/Default

Rest of site : http://filmyoze

Share Improve this question edited Mar 8, 2019 at 21:45 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Mar 8, 2019 at 19:41 Talha khanTalha khan 531 silver badge11 bronze badges 1
  • Duplicate - why did you ask this question twice instead of updating the first question if the answer there did not help? wordpress.stackexchange/questions/330994/… – WebElaine Commented Mar 8, 2019 at 20:23
Add a comment  | 

2 Answers 2

Reset to default 4

This code may help resolve the issue for this particular situation. Put this code in yor theme's functions.php.

add_action('template_redirect', 'default_page');
function default_page(){
    if(is_home() or is_front_page()){
       exit( wp_redirect("http://path/to/your/html/file"));
    }
}

Replace http://path/to/your/html/file to exact url of html file.

I hope this helps.

WordPress relies on all WordPress requests being routed to index.php, which kicks off the whole WordPress lifecycle and then serves up the proper page, content, etc. (This is true for everything except requests to other real, existing files, like images and external pages that don't need WordPress.)

If you want your custom page to be the home page of your site, but live within WordPress (which is usually the case), then you need to operate within WordPress's world. That means you don't just stick a file in your directory, and you certainly don't replace WordPress's index.php file.

Instead, you create a page template and a page within WordPress to use it. Basically:

  1. Create a page in WordPress
  2. On your WordPress dashboard, go to Settings -> Reading and for Front Page choose the page you created
  3. In your site's directory, name your file front-page.php
  4. In front-page.php, at a minimum, put the PHP calls to get_header() before your content, and get_footer() after your content

With those steps, WordPress will capture all requests to your home page, and serve the page you created (in step 1) using the template you created (in steps 3 & 4). You can then go further and store front page content (i.e. content, meta data, etc.) on that WordPress page, and pull it into your page template dynamically.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748827852a314056.html

最新回复(0)