wordpresswordpress-themingfrontpagestatic-pages

How to link to index.php from static page in 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.


Solution

  • 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