Make custom wordpress page the proper way

I would need to make a few custom pages on a site using wordpress. This involves:

Adding tables into the Database
Making a page that adds entries to the new tables based on a submitted form
making a page that displays those values in a structured way.

Read More

What i need:

  • To understand how to include this page in the existing layout (header etc..) and having access to the user session, ((custom page template??))
  • To understand the PROPER way to access the custom database tables from a custom page keeping in mind point 1,

I have already done things like this in the past but given that i have almost zero experience with wordpress i built a custom mysqli connection for those extra tables. Also the session integration and such have included in a non-proper way. I would like to make things the proper way this time around.

sample table:

cabinets

| id | lenght | height | width |
  1      1200    3000     300
  2      1200    2800     600

Related posts

Leave a Reply

2 comments

  1. Go to your WP directory, wp-content-> themes-> your_theme

    make any simple php file

    <?php
    // Template Name: custom_page
    get_header();
    ?>
    your custom contents
    
    <?php get_footer(); ?>
    

    Then go to WP_ADMIN choose any page or create new page, go to Page Attribute, you will find “custom_page” in Template Selction list..

    for more details you can check this link

    Edit :

    No need to include or config extra database file, u can call it directly as all connections are already defined in header part.. you just try to add table and write simple query for fetching single result..it will work like charm..good luck..

    EDIT 2
    You can write query according to ur sql or sqli..

    <?php
    // Template Name: custom_page
    get_header(); global $data;
    
    $query = "SELECT id,lenght, height, width 
    FROM cabinets";
    $result = mysql_query($query);
    while($row = mysql_fetch_assoc($result))
    {
        echo " ".$row['lenght']. " , " .$row['height']. " , " .$row['width']. " ";
    }
    ?>
    
    
    <?php get_footer(); ?>
    
  2. Create custom templplate

    <?php
    /*
       template name:mytemplate
    */
     //get_header();
    ?>
    hhhhhhhhh
    <?php //get_footer(); ?>
    

    after that you can select it at any page to customize accordingly .