• Like sample page in the wordpress pages section that is already there when we install wordpress.

    I want to add my pages into the database “wp_post” table which contain textual information about the theme when my theme is activated.

    Any suggestion???

    Thanks in advance

Viewing 1 replies (of 1 total)
  • Thread Starter mdkhan

    (@mdkhan)

    Thank you very much I figure it out.
    below is the solution for someone who dont know about these hooks.

    There are hooks which you can call to insert pages.

    1- after_switch_theme hook is called when you switch theme (available if your wp version > 3.3.0 ) hook reference

    2- wp_insert_post is used to create pages/post (more documentation at wp_insert_post)

    Below code will be in your theme functions.php

    <?php
    function myactivationfunction($oldname, $oldtheme=false) {
    
    }
    add_action("after_switch_theme", "myactivationfunction", 10 ,  2);

    Reference : here explained in more details regarding activation and deactivation of theme

Viewing 1 replies (of 1 total)
  • The topic ‘Auto Page insertion in db when theme activated’ is closed to new replies.