2

私はWordPressが初めてです。最近、自分の HTML Web サイトを作成し、WordPress に変換しました。WordPressでは問題なく動作しています。しかし、1 つ問題があります。それは、WordPress を介して Web サイトのコンテンツを変更できないことです。テーマの index.php に html をコーディングしたためかもしれませんが、効果があるかどうかはわかりません。現在、私のテーマには次のファイルがあります。

  1. index.php

  2. フッター.php

  3. header.php

  4. スタイル.css

  5. スクリーンショット.png

  6. css(フォルダ)

  7. js(フォルダ)

  8. フォント(フォルダ)

  9. img(フォルダ)

どんな種類の助けも大歓迎です。

4

1 に答える 1

1

index.php ですべての html をハードコーディングしないでください。代わりに、WP ループを使用してテンプレートを作成し、これらのテンプレートを使用して Wordpress Admin でページを作成します。たとえば、Twenty Fifteen Wordpress テーマを使用している場合、メイン テンプレートは次のようになります。

 <?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(); ?>

次に、フロント ページを作成します。[ページ] で [新しいページを追加] を選択します。題名は「ホーム」。HTML 動的コンテンツをコンテンツ領域に配置します。前に作成したテンプレート Front_Page を選択します (右側のサイド バーから)。詳細については、WP codex リンクを参照してください: WordPress Static Front Page Process

ページのコンテンツを変更するには、WP 管理パネルでページを編集するだけです。お役に立てれば。

編集 1: スタイル シートと Js ファイルは、従来と同じようにヘッダー ファイルに、またはテーマの function.php を介してキューに入れることができます。詳細については、 CSS と JavaScript を含めるおよびwp_enqueue_styleを参照してください。

編集2:はい、既存のテーマを使用してカスタマイズするか、既存のテーマWP子テーマを使用して独自の子テーマを作成することをお勧めします

于 2016-04-14T08:47:51.007 に答える