2
votes

I am new to WordPress. i recently made my own html website and converted it to WordPress. It is working fine in WordPress. But have one problem and that is I can not change the content of the website through WordPress. Maybe it is because i coded html in the index.php of my theme, but i am not sure whether that has any effect. Right now my theme has the following files:

  1. index.php

  2. footer.php

  3. header.php

  4. style.css

  5. screenshot.png

  6. css(folder)

  7. js(folder)

  8. fonts(folder)

  9. img(folder)

Any kind of help will be greatly appreciated.

1
Which section of your WordPress site are you trying to edit? You need a template for each part. - Danny Cullen
What theme you are using ?? - Amar Pratap
i am just trying to edit the contents of my page through wordpress. and also every new page i create looks exaclty the same. i know it is because i coded html to index.php file. - Sherry Malik
EntrePrAmar I am not using any theme. i made the wordpress theme from my own custom html files. - Sherry Malik
@SHARJEELIMTIAZ, yes templates are php files and WP pages are dynamic content being rendered using these templates. See my answers below. - Amar Pratap

1 Answers

1
votes

Dont hard code the all your html in your index.php instead create templates using WP loop and then create your pages in Wordpress Admin using these templates. For example if you are using Twenty Fifteen Wordpress theme, Your main template can be similar to this:

 <?php
/**
 * The main template file
 * Template Name: Front_Page
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * e.g., it puts together the home page when no home.php file exists.
 *
 * Learn more: {@link https://codex.wordpress.org/Template_Hierarchy}
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */
    get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">

        <?php if ( have_posts() ) : ?>

            <?php if ( is_home() && ! is_front_page() ) : ?>
                <header>
                    <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                </header>
            <?php endif; ?>

            <?php
            // Start the loop.
            while ( have_posts() ) : the_post();

                /*
                 * Include the Post-Format-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

            // End the loop.
            endwhile;

            // Previous/next page navigation.
            the_posts_pagination( array(
                'prev_text'          => __( 'Previous page', 'twentyfifteen' ),
                'next_text'          => __( 'Next page', 'twentyfifteen' ),
                'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
            ) );

        // If no content, include the "No posts found" template.
        else :
            get_template_part( 'content', 'none' );

        endif;
        ?>

        </main><!-- .site-main -->
    </div><!-- .content-area -->

<?php get_footer(); ?>

Then create a Front Page: In Pages choose Add New Page. Title it "Home". Put your html dynamic contents in the content area. Choose the template Front_Page that you created earlier (From right side bar). See the WP codex link for more details: WordPress Static Front Page Process

Now to change the content of the page you will just have to edit the pages in WP admin panel. Hope this helps.

Edit 1: You can enqueue your style sheets and Js files either in your header file as you do traditionally or through function.php of the theme. See Including CSS & JavaScript and wp_enqueue_style for info.

Edit 2: Yes better use an existing theme and customize it or make a child theme of your own using the existing theme WP Child Theme