NO IMAGE

WordPressの組み込み

更新は行ないたいが、静的なページもある。
ということで、下層にWordPressを入れ込んで、ロードさせることにしてみる……行なう。

現在のディレクトリー構成は、Web_root直下にあるので、

web_root
 ├ 静的ファイルフォルダ
 ├ WP  (WordPress 格納)
 ├  静的ページ
 ├  デモページとか?
 ├

下層に入れて、トップにindex.phpを配置。

load.phpを読み込む

躓く:サーバーphp バージョン古かった、イラついたのでphp7.0.7にする。

記事一覧を読み込む。

テーマのtwentyseventeenを確認

			<?php
			if ( have_posts() ) :

				/* 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( 'template-parts/post/content', get_post_format() );

				endwhile;

				the_posts_pagination( array(
					'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
					'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
					'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
				) );

			else :

				get_template_part( 'template-parts/post/content', 'none' );

			endif;
			?>

テンプレートは’template-parts/post/content’, とあるので、この部分を参考に

躓き:get_postじゃないとだめか

      <ul>
      <?php
      $posts = get_posts(); 
      global $post;
      ?>
      <?php
      if($posts): foreach($posts as $post): setup_postdata($post); ?>
      <li><a href="<?php the_permalink();?>">
      <?php the_time( 'Y/m/d' ); ?>:<br /> 「<?php the_title(); ?>」
      </a></li>
      <?php endforeach; endif;
      ?>
      </ul>

 

@See http://hijiriworld.com/web/wordpress-loop/

そういうこと(´・ω・) スか……

 

NO IMAGE
最新情報をチェックしよう!

    Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 37

    Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 38

    Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 39

  • Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 83

    Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 84

    Warning: Trying to access array offset on value of type bool in /home/xsvx1010357/kato.space/public_html/wp/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 85
>最強のWordPressテーマ「THE THOR」

最強のWordPressテーマ「THE THOR」

システムの構築・保守運用「   」 社内システム担当が欲しいが、専属で雇うほどの仕事量はない。 必要な時に必要なだけ頼りたいというお悩みを持つ企業様へ専門知識を持って対応を行っております。 サーバから各種システムまで自社・他社で構築されたシステムに対してサポートを行っております。

CTR IMG