質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

0回答

592閲覧

ワードプレスのホームのトップ画像が表示されない。

2232

総合スコア298

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2021/12/09 05:26

編集2021/12/10 02:39

初心者です。
ワードプレスで作った、ホームのトップ画像が表示されない場合の直し方を教えていただけないでしょうか?
どのPHPのどこを直せばいいのか分かりません。

CSSとHTMLは元のデータから変化させていません

header.php

PHP

1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 <meta charset="utf-8" /> 5 <meta name="viewport" content="width=device-width,initial-scale=1" /> 6 <meta name="keywords" content="共通キーワード" /> 7 <meta name="description" content="<?php bloginfo( 'description' ); ?>" /> 8 <title><?php bloginfo( ‘name’ ); ?></title> 9 <link rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/assets/images/common/favicon.ico" /> 10 <link href="https://fonts.googleapis.com/earlyaccess/notosansjapanese.css" rel="stylesheet" /> 11 <link href="https://fonts.googleapis.com/css?family=Vollkorn:400i" rel="stylesheet" /> 12<?php wp_head(); ?> 13</head> 14<body <?php body_class(); ?>> 15 <div class="container"> 16 <header id="header"> 17 <div class="header-inner"> 18 <div class="logo"> 19 <a class="logo-header" href="/"> 20 <img src="<?php echo get_template_directory_uri(); ?>/assets/images/common/logo-main.svg" class="main-logo" alt="PACIFIC MALL DEVELOPMENT" /> 21 <img src="<?php echo get_template_directory_uri(); ?>/assets/images/common/logo-fixed.svg" class="fixed-logo" alt="PACIFIC MALL DEVELOPMENT" /> 22 </a> 23 </div> 24 <button class="toggle-menu js-toggoleNav"> 25 <span class="toggle-line">メニュー</span> 26 </button> 27 <div class="header-nav"> 28 <nav class="global-nav"> 29<?php 30wp_nav_menu( 31 array ( 32 'theme_location' => 'place_global', 33 'container' => false, 34 ) 35); 36?> 37 </nav> 38 <form class="search-form" role="search" method="get" action="<?php echo esc_url( home_url() ); ?>"> 39 <div class="search-box"> 40 <input type="text" class="search-input" name="s" placeholder="キーワードを入力してください" /> 41 <button type="submit" class="button-submit"></button> 42 </div> 43 <div class="search-buttons"> 44 <button type="button" class="close-icon js-searchIcon"></button> 45 <button type="button" class="search-icon js-searchIcon"></button> 46 </div> 47 </form> 48 </div> 49 </div> 50 </header> 51<?php if( is_front_page() ): ?> 52 <section class="section-contents" id="keyvisual"> 53 <?php echo get_main_image(); ?> 54 <div class="wrapper"> 55 <h1 class="site-title">Connecting the future.</h1> 56 <p class="site-caption"><?php echo get_the_excerpt(); ?></p> 57 </div> 58 </section> 59<?php else: ?> 60 <div class="wrap"> 61 <div id="primary" class="content-area"> 62 <main> 63 <div class="page-contents"> 64 <div class="page-head"> 65 <?php echo get_main_image(); ?> 66 <div class="wrapper"> 67 <span class="page-title-en"><?php echo get_main_en_title(); ?></span> 68 <h2 class="page-title"><?php echo get_main_title(); ?></h2> 69 </div> 70 </div> 71 <div class="page-container"> 72<?php 73if ( function_exists('bread_crumb') ){ 74 bread_crumb(); 75} 76?> 77<?php endif; ?>

functions.php

PHP

1<?php 2function my_enqueue_scripts() { 3 wp_enqueue_script( 'jquery' ); 4 wp_enqueue_script( 'bundle_js', get_template_directory_uri(). '/assets/js/bundle.js', array() ); 5 wp_enqueue_style( 'my_styles', get_template_directory_uri(). '/assets/css/styles.css', array() ); 6} 7add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' ); 8 9// ヘッダー、フッターのカスタムメニュー化 10register_nav_menus( 11 array( 12 'place_global' => ' グローバル', 13 'place_footer' => ' フッターナビ', 14 ) 15); 16 17// メイン画像上にテンプレートごとの文字列を表示 18function get_main_title() { 19 if ( is_singular( 'post' ) ): 20 $category_obj = get_the_category(); 21 return $category_obj[0]->name; 22 elseif ( is_page() ): 23 return get_the_title(); 24 elseif ( is_category() || is_tax() ): 25 return single_cat_title(); 26 elseif ( is_search() ): 27 return ' サイト内検索結果'; 28 elseif ( is_404() ): 29 return ' ページが見つかりません'; 30 elseif ( is_singular( 'daily_contribution' ) ): 31 global $post; 32 $term_obj = get_the_terms( $post->ID, 'event' ); 33 return $term_obj[0]->name; 34 endif; 35} 36 37// 子ページを取得する関数 38function get_child_pages( $number = -1, $specified_id = null ) { 39 if ( isset( $specified_id ) ): 40 $parent_id = $specified_id; 41 else: 42 $parent_id = get_the_ID(); 43 endif; 44 $args = array( 45 'posts_per_page' => $number, 46 'post_type' => 'page', 47 'orderby' => 'menu_order', 48 'order' => 'ASC', 49 'post_parent' => $parent_id, 50 ); 51 $child_pages = new WP_Query( $args ); 52 return $child_pages; 53} 54 55// アイキャッチ画像を利用できるようにする 56add_theme_support( 'post-thumbnails' ); 57 58// トップページのメイン画像用のサイズ設定 59add_image_size( 'top', 1077, 622, true ); 60 61// 地域貢献活動一覧画像用のサイズ設定 62add_image_size( 'contribution', 557, 280, true ); 63 64// トップページの地域貢献活動にて使用している画像用のサイズ設定 65add_image_size( 'front-contribution', 255, 189, true ); 66 67// 企業情報・店舗情報一覧画像用のサイズ設定 68add_image_size( 'common', 465, 252, true ); 69 70// 各ページのメイン画像用のサイズ設定 71add_image_size( 'detail', 1100, 330, true ); 72 73// 検索一覧画像用のサイズ設定 74add_image_size( 'search', 168, 168, true ); 75 76// 各テンプレートごとのメイン画像を表示 77function get_main_image() { 78 if ( is_page() || is_singular( 'daily_contribution' ) ): 79 $attachment_id = get_field( 'main_image' ); 80 if ( is_front_page() ): 81 return wp_get_attachment_image( $attachment_id, 'top' ); 82 else: 83 return wp_get_attachment_image( $attachment_id, 'detail' ); 84 endif; 85 elseif ( is_category( 'news' ) || is_singular( 'post' ) ): 86 return '<img src="'. get_template_directory_uri(). '/assets/images/bg-page-news.jpg" />'; 87 elseif ( is_search() || is_404() ): 88 return '<img src="'. get_template_directory_uri() .'/assets/images/bg-page-search.jpg">'; 89 elseif ( is_tax( 'event' ) ): 90 $term_obj = get_queried_object(); 91 $image_id = get_field( 'event_image', $term_obj->taxonomy. '_'. $term_obj->term_id ); 92 return wp_get_attachment_image( $image_id, 'detail' ); 93 else: 94 return '<img src="'. get_template_directory_uri(). '/assets/images/bg-page-dummy.png" />'; 95 endif; 96} 97 98// 特定の記事を抽出する関数 99function get_specific_posts( $post_type, $taxonomy = null, $term = null, $number = -1 ) { 100 if ( ! $term ): 101 $terms_obj = get_terms( 'event' ); 102 $term = wp_list_pluck( $terms_obj, 'slug' ); 103 endif; 104 105 $args = array( 106 'post_type' => $post_type, 107 'tax_query' => array( 108 array( 109 'taxonomy' => $taxonomy, 110 'field' => 'slug', 111 'terms' => $term, 112 ), 113 ), 114 'posts_per_page' => $number, 115 ); 116 $specific_posts = new WP_Query( $args ); 117 return $specific_posts; 118} 119 120function cms_excerpt_more() { 121 return '...'; 122} 123add_filter( 'excerpt_more', 'cms_excerpt_more' ); 124 125function cms_excerpt_length() { 126 return 80; 127} 128add_filter( 'excerpt_mblength', 'cms_excerpt_length' ); 129 130// 抜粋機能を固定ページに使えるよう設定 131add_post_type_support( 'page', 'excerpt' ); 132 133function get_flexible_excerpt( $number ) { 134 $value = get_the_excerpt(); 135 $value = wp_trim_words( $value, $number, '...' ); 136 return $value; 137} 138 139//get_the_excerpt() で取得する文字列に改行タグを挿入 140function apply_excerpt_br( $value ) { 141 return nl2br( $value ); 142} 143add_filter( 'get_the_excerpt', 'apply_excerpt_br' ); 144 145// ウィジェット機能を有効化 146function theme_widgets_init() { 147 register_sidebar( array( 148 'name' => ' サイドバーウィジェットエリア', 149 'id' => 'primary-widget-area', 150 'description' => ' 固定ページのサイドバー', 151 'before_widget' => '<aside class="side-inner">', 152 'after_widget' => '</aside>', 153 'before_title' => '<h4 class="title">', 154 'after_title' => '</h4>', 155 ) ); 156} 157add_action( 'widgets_init', 'theme_widgets_init' ); 158 159// メイン画像上にテンプレートごとの英語タイトルを表示 160function get_main_en_title() { 161 if ( is_category() ): 162 $term_obj = get_queried_object(); 163 $english_title = get_field( 'english_title', $term_obj->taxonomy. '_'. $term_obj->term_id ); 164 return $english_title; 165 elseif ( is_singular( 'post' ) ): 166 $term_obj = get_the_category(); 167 $english_title = get_field( 'english_title', $term_obj[0]->taxonomy. '_'. $term_obj[0]->term_id ); 168 return $english_title; 169 elseif ( is_page() || is_singular( 'daily_contribution' ) ): 170 return get_field( 'english_title' ); 171 elseif ( is_search() ): 172 return 'Search Result'; 173 elseif ( is_404() ): 174 return '404 Not Found'; 175 elseif ( is_tax() ): 176 $term_obj = get_queried_object(); 177 $english_title = get_field( 'english_title', $term_obj->taxonomy. '_'. $term_obj->term_id ); 178 return $english_title; 179 endif; 180} 181 182function set_revision_store_number($num){ 183 return 3; 184 } 185 add_filter( 'wp_revisions_to_keep', 'set_revision_store_number');

page.php

PHP

1<?php get_header(); ?> 2<div class="page-main"> 3 <div class="lead-inner"> 4 <?php 5 if(have_posts()): 6 while(have_posts() ):the_post(); 7 the_content(); 8 endwhile; 9 endif; 10 ?> 11 </div> 12</div> 13<?php get_footer(); ?>

デベロッパーツールは
navigator.userAgent、navigator.appVersion、およびnavigator.platformの用法を監査しなさい

ページまたはスクリプトは、navigator.userAgent、navigator.appVersion、およびnavigator.platformのうちの最低1つにアクセスしている。クロム101を始めることによって、ユーザーエージェントストリングで入手可能な情報の量が減らされる。
この問題を定着させるためには、navigator.userAgent、navigator.appVersion、およびnavigator.platformの用法を機能検出、進歩的な向上と取り替えるか、またはnavigator.userAgentDataに移住しなさい。
性能理由のためにプロパティのうちの1つへの最初のアクセスだけが示されることに注意しなさい。

と出てきます。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

CHERRY

2021/12/09 09:07

どのように作成したのかによって 変わると思います。 どのような HTML や CSS / PHP コードを記載されているのでしょうか? また、Web ブラウザのデベロッパーツールで、なにかエラーが出ていたりしますか?
2232

2021/12/10 02:39

返信いただき誠にありがとうございます、 修正しました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問