「メイド・イン・ヘブン」スキン適用中

Cocoonフォーラム

サイト内検索
書き込みの前に以下の3点をご確認ください。
  1. 1つのトピックにつき1つの質問を書き込んでください
  2. 不具合・カスタマイズ対象ページのURLを提示高速化を無効にしてください
  3. 該当部分のキャプチャ・環境情報とともに書き込んでいただけると助かります

何を書き込んだら良いか分からない場合は、以下のテンプレートをコピペしてご利用ください。

不具合・カスタマイズ対象ページのURL:

相談内容:

不具合の発生手順:

解決のために試したこと:

※文字だけでは正しく伝わらない可能性があるため、スクショ画像の添付もお願いします。
※高速化設定をしている場合は無効にしてください。
環境情報:

※↑こちらに「Cocoon設定 → テーマ情報」にある「環境情報」を貼り付けてください。

環境情報の取得方法はこちら。
https://wp-cocoon.com/theme-report/
高速化設定を無効にするにはこちら。
https://wp-cocoon.com/theme-trouble/

フォーラム利用ガイドリンク

  1. フォーラムガイドライン
  2. よくある質問と答え(FAQ)
  3. サポート対象外のケース
  4. 原因不明の不具合用トラブルシューティング
  5. トピックにHTMLを貼り付ける方法(推奨ツール:notepad.pw
  6. 真っ白画面でのエラーメッセージの確認方法
  7. ブラウザ環境チェックツール
  8. Cocoonカスタマイズ依頼

フォーラム質問後、問題等が解決した場合は結果を書き込んでいただけると幸いです。同様の問題で調べている方には、結果が一番気になる部分となります。

インデックスページの「エントリーカード...
 
共有:
通知
すべてクリア

[解決済] インデックスページの「エントリーカードとエントリーカードの間の改行」がどうしても消せず、空白が出来てしまいます。

4 投稿
3 ユーザー
6 Likes
825 表示
(@yoshiyoshi0210)
Active Member Registered
結合: 1年前
投稿: 2
Topic starter  

インデックスページの「エントリーカードとエントリーカードの間の改行」がどうしても消せず、空白が出来てしまいます。list.phpやentry-card.phpをいじった事が影響していると思うのですが、僕の知識ではどうしても要因が特定出来ず・・・。

インデックスページをブラウザでソースをコピーしてテキストエディタに張り付けると、空白部分に「?」が表示されているので、何かしらが挟まっているとは思うのですが、それが何なのかが分かりません。

上記、改行(空白)を取る方法をご教授頂けますと幸いです。

対象のサイト(制作中)は
https://www.odekake.kids/
で、解決したい部分はトップページのエントリーカードが並んでいるエリア(カテゴリ別一覧ページやタグ別一覧ページも同様)となります。

----------------------------------------------
サイト名:おでかけキッズ
サイトURL: https://www.odekake.kids 
ホームURL: https://www.odekake.kids 
コンテンツURL:/wp-content
インクルードURL:/wp-includes/
テンプレートURL:/wp-content/themes/cocoon-master
スタイルシートURL:/wp-content/themes/cocoon-child-master
親テーマスタイル:/wp-content/themes/cocoon-master/style.css
子テーマスタイル:/wp-content/themes/cocoon-child-master/style.css
スキン:/wp-content/themes/cocoon-child-master/skins/skin-season-use/style.css
WordPressバージョン:6.2
PHPバージョン:7.4.33
ブラウザ:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
サーバーソフト:Apache
サーバープロトコル:HTTP/1.1
言語:ja,en-US;q=0.9,en;q=0.8
----------------------------------------------
テーマ名:Cocoon
バージョン:2.5.8.3
カテゴリー数:42
タグ数:39
ユーザー数:1
----------------------------------------------
子テーマ名:Cocoon Child
バージョン:1.1.3
style.cssサイズ:2494バイト
functions.phpサイズ:1964バイト
----------------------------------------------
Gutenberg:1
AMP:0
PWA:0
Font Awesome:4
Auto Post Thumbnail:0
Retina:0
ホームイメージ: http://odekake.kids/wp-content/themes/cocoon-master/screenshot.jpg 
----------------------------------------------
ブラウザキャッシュ有効化:0
HTML縮小化:0
CSS縮小化:0
JavaScript縮小化:0
Lazy Load:0
----------------------------------------------
利用中のプラグイン:
Regenerate Thumbnails 3.1.5
Sitemap Generator 4.1.9
WP ULike 4.6.7
----------------------------------------------

 

■ファイルソース①(entry-card.php)

<?php //エントリーカード
/**
* Cocoon WordPress Theme
* @author: yhira
* @link: https://wp-cocoon.com/
* @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
*/
if ( !defined( 'ABSPATH' ) ) exit;
$article_id_attr = null;
if (is_front_page_type_index()) {
$article_id_attr = ' id="post-'.get_the_ID().'"';
}
?>
<a href="<?php echo esc_url(get_the_permalink()); ?>" class="entry-card-wrap a-wrap border-element cf" title="<?php echo esc_attr(get_the_title()); ?>">
<article<?php echo $article_id_attr; ?> <?php post_class( array('post-'.get_the_ID(), 'entry-card','e-card', 'cf') ); ?>>
<figure class="entry-card-thumb card-thumb e-card-thumb">
<?php
//サムネイルタグを取得
$thumbnail_tag =
get_the_post_thumbnail(
get_the_ID(),
get_entry_card_thumbnail_size($count),
array(
'class' => 'entry-card-thumb-image card-thumb-image',
'alt' => '',
'loading' => 'lazy',
'decoding' => 'async',
)
);
// サムネイルを持っているとき
if ( has_post_thumbnail() && $thumbnail_tag ): ?>
<?php echo $thumbnail_tag; ?>
<?php else: ?>
<?php echo get_entry_card_no_image_tag($count); ?>
<?php endif; ?>
<?php the_nolink_category(null, apply_filters('is_entry_card_category_label_visible', true)); //カテゴリーラベルの取得 ?>
</figure><!-- /.entry-card-thumb -->
<div class="entry-card-content card-content e-card-content">
<div class="entry-card-categories-ex"><object><?php the_category_links() ?></object></div>
<h2 class="entry-card-title card-title e-card-title" itemprop="headline"><?php the_title() ?></h2>
<?php //スニペットの表示
if (is_entry_card_snippet_visible()): ?>
<div class="entry-card-snippet card-snippet e-card-snippet">
<?php echo get_the_snippet( get_the_content(''), get_entry_card_excerpt_max_length() ); //カスタマイズで指定した文字の長さだけ本文抜粋?>
</div>
<?php //タグの表示 ?>
<?php $search1 = '/歳|の子/';?>
<?php $tags = get_the_tags(); if ( $tags ) : ?>
<?php echo "<div align='right' class='entry-card-tags-ex' tabindex='0'><object>"; ?>
<?php foreach ( $tags as $tag ): ?>
<?php
if(preg_match($search1, $tag->name) === 1){
echo "<a class='tag-link tag-link-48 border-element' href='/tag/";
echo esc_html( $tag->slug);
echo "/'><span class='fa fa-tag tag-icon tax-icon' aria-hidden='true'></span>";
echo esc_html( $tag->name );
echo "</a>";
}
?>
<?php endforeach; ?>
<?php echo "</object>"; ?>
<?php endif; ?>
<?php
if (is_entry_card_post_date_visible() || (is_entry_card_post_date_or_update_visible() && !$update_time && is_entry_card_post_update_visible())): ?>
<span class="post-date"><span class="fa fa-clock-o" aria-hidden="true"></span><span class="entry-date"><?php the_time(get_site_date_format()); ?></span></span>
<?php endif ?>
<?php echo "</div>"; ?>
<?php endif ?>
<?php do_action( 'entry_card_snippet_after', get_the_ID() ); ?>
<?php //PVエリアの表示
if (is_admin_index_pv_visible() && is_user_administrator() || apply_filters('public_page_entry_card_pv_visible', false)) {
get_template_part('tmp/admin-pv');
} ?>
<div class="entry-card-meta card-meta e-card-meta">
<div class="entry-card-info e-card-info">
<?php
//更新日の取得
$update_time = get_update_time(get_site_date_format());
//投稿日の表示
if (is_entry_card_post_date_visible() || (is_entry_card_post_date_or_update_visible() && !$update_time && is_entry_card_post_update_visible())): ?>
<?php endif ?>
<?php //更新時の表示
if (is_entry_card_post_update_visible() && $update_time && (get_the_time('U') < get_update_time('U'))): ?>
<span class="post-update"><span class="fa fa-history" aria-hidden="true"></span><span class="entry-date"><?php echo $update_time; ?></span></span>
<?php endif ?>
<?php //投稿者の表示
if (is_entry_card_post_author_visible()): ?>
<span class="post-author">
<span class="post-author-image"><?php echo get_avatar( get_the_author_meta( 'ID' ), '16', null ); ?></span>
<span class="post-author-name"><?php echo get_the_author(); ?></span>
</span>
<?php endif ?>
<?php //コメント数の表示
$count = get_comments_number();
if(is_entry_card_post_comment_count_visible() && is_single_comment_visible() && apply_filters('entry_card_post_comment_count_visible', true, $count)): ?>
<span class="post-comment-count"><span class="fa fa-comment-o" aria-hidden="true"></span> <?php echo $count; ?></span>
<?php endif; ?>
</div>
<div class="entry-card-categorys e-card-categorys"><?php the_nolink_categories() ?></div>
</div>
</div>
<!-- /.entry-card-content -->
</article>
</a>

 

■ファイルソース②(list.php)

<?php //一覧
/**
* Cocoon WordPress Theme
* @author: yhira
* @link: https://wp-cocoon.com/
* @license: http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
*/
if ( !defined( 'ABSPATH' ) ) exit;

////////////////////////////
//アーカイブのタイトル
////////////////////////////
if ( is_category() ){
////////////////////////////
//カテゴリーページのパンくずリスト
////////////////////////////
if (is_single_breadcrumbs_position_main_top()) {
get_template_part('tmp/breadcrumbs');
}

////////////////////////////
//カテゴリーページのコンテンツ
////////////////////////////
if (!is_paged()) {
get_template_part('tmp/category-content');
} else {
get_template_part('tmp/list-title');
}
} elseif ( (is_tag() || is_tax()) && !is_paged() ) {
get_template_part('tmp/tag-content');
} elseif (!is_home()) {
//それ以外
get_template_part('tmp/list-title');
}

////////////////////////////
//子カテゴリだけのリスト
////////////////////////////

if ( is_category() === true ) {
$categories = get_categories( array(
'parent' => get_query_var( 'cat' ),
) );

if ( $categories ) : ?>
<p style="background-color: #9b7b6c; padding-left: 10px; padding-top: 3px; padding-bottom: 3px; color: #ffffff; font-weight:bold; margin-top: 20px; margin-bottom: 20px;">お出かけ施設一覧</p>

<table>
<tr>
<th>施設名</th>
<th>所在地</th>
</tr>

<?php foreach ( $categories as $category ) : ?>

<tr data-href="<?php echo get_category_link( $category->cat_ID ); ?>">
<td height="70″style="font-weight:bold;"><?php echo $category->cat_name; ?></td>
<td><?php echo $category->category_description; ?></td></a>
</tr>

<?php endforeach; ?>

</table>

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

<script>
<!--trのhrefでリンク先に飛ぶコード-->
jQuery(function ($) {
$("tbody tr[data-href]")
.addClass("clickable")
.click(function () {
window.location = $(this).attr("data-href");
})
.find("a")
.hover(
function () {
$(this).parents("tr").unbind("click");
},
function () {
$(this)
.parents("tr")
.click(function () {
window.location = $(this).attr("data-href");
});
}
);
});
</script>

<p style="background-color: #9b7b6c; padding-left: 10px; padding-top: 3px; padding-bottom: 3px; color: #ffffff; font-weight:bold; margin-top: 20px; margin-bottom: 20px;">記事一覧</p>

<?php endif;
}

////////////////////////////
//インデックストップ広告
////////////////////////////
if (is_ad_pos_index_top_visible() && is_all_adsenses_visible()){
//レスポンシブ広告
get_template_part_with_ad_format(get_ad_pos_index_top_format(), 'ad-index-top', is_ad_pos_index_top_label_visible());
};

////////////////////////////
//インデックスリストトップウィジェット
////////////////////////////
if ( is_active_sidebar( 'index-top' ) ){
dynamic_sidebar( 'index-top' );
};

////////////////////////////
// トップシェアボタン
////////////////////////////
//SNSトップシェアボタンの表示
if (is_sns_top_share_buttons_visible() &&
//フロントページトップシェアボタンの表示
(is_front_page() && !is_paged() && is_sns_front_page_top_share_buttons_visible())
){
get_template_part_with_option('tmp/sns-share-buttons', SS_TOP);
} ?>

<?php
if (is_front_top_page() && is_front_page_type_tab_index()) {
get_template_part('tmp/list-tab-index');
} elseif (is_front_top_page() && is_front_page_type_category()) {
get_template_part('tmp/list-category');
} elseif ((is_front_top_page() && is_front_page_type_category_2_columns()) || is_front_top_page() && is_front_page_type_category_3_columns()) {
get_template_part('tmp/list-category-columns');
} else {
get_template_part('tmp/list-index');
}
?>

<?php
////////////////////////////
//インデックスボトム広告
////////////////////////////
if (is_ad_pos_index_bottom_visible() && is_all_adsenses_visible()){
//レスポンシブ広告のフォーマットにrectangleを指定する
get_template_part_with_ad_format(get_ad_pos_index_bottom_format(), 'ad-index-bottom', is_ad_pos_index_bottom_label_visible());
};

////////////////////////////
//インデックスリストボトムウィジェット
////////////////////////////
if ( is_active_sidebar( 'index-bottom' ) ){
dynamic_sidebar( 'index-bottom' );
};

////////////////////////////
//フロントページボトムシェアボタン
////////////////////////////
//SNSボトムシェアボタンの表示
if (is_sns_bottom_share_buttons_visible() && !is_paged() &&
(
//フロントページボトムシェアボタンの表示
(is_front_page() && is_sns_front_page_bottom_share_buttons_visible()) ||
//カテゴリーページトップシェアボタンの表示
(is_category() && is_sns_category_bottom_share_buttons_visible()) ||
//タグページトップシェアボタンの表示
(is_tag() && is_sns_tag_bottom_share_buttons_visible())
)

){
get_template_part_with_option('tmp/sns-share-buttons', SS_BOTTOM);
}

////////////////////////////
//フロントページフォローボタン
////////////////////////////
//SNSフォローボタンの表示
if (is_sns_follow_buttons_visible() && !is_paged() &&
(
//フロントページフォローボタンの表示
(is_front_page() && is_sns_front_page_follow_buttons_visible()) ||
//カテゴリーページボトムフォローボタンの表示
(is_category() && is_sns_category_follow_buttons_visible()) ||
//タグページボトムフォローボタンの表示
(is_tag() && is_sns_tag_follow_buttons_visible())
)

){
get_template_part_with_option('tmp/sns-follow-buttons', SF_BOTTOM);
}

////////////////////////////
//ページネーション
////////////////////////////
if (is_front_page_type_index() || !is_front_top_page()) {
get_template_part('tmp/pagination');
}

////////////////////////////
//カテゴリーページのパンくずリスト
////////////////////////////
if (is_category() && is_single_breadcrumbs_position_main_bottom()){
get_template_part('tmp/breadcrumbs');
}

////////////////////////////
//メインカラム追従領域
////////////////////////////
get_template_part('tmp/main-scroll'); ?>


   
はる
(@haruinoue)
Noble Member Moderator
結合: 4年前
投稿: 1067
 

エントリーカード間に挿入されているのは「&#xFEFF」のようです。

文字コードや改行コードを確認してphpファイルを再保存したり、全体をコピーしてプレーンテキストで貼り付け直したりしてみてはいかがでしょうか。

参考:phpでファイルをinclude時に謎の空白行が入る問題を解決
   WordPressの上部に謎の余白ができた!原因と対策方法まとめ
   書式なし(プレーン)テキストとして貼り付けたい場合は[Windows]+[V]がお勧め


   
mk2
(@mk2_mk2)
Illustrious Member Moderator
結合: 3年前
投稿: 6961
 

各カードの間以外にも、「&#xFEFF」は入っているかもしれないです。

 
BOMなのではないかという気はします。
 
UTF-8, UTF-16, UTF-32 & BOM
 
UFT-16BEのBOMは「FEFF」みたいです。
 
また、添付画像では、&の前に何かあるように見えますので、もしかすると、UFT-32BE(こちらは0000 FEFF)なのかもしれないです。
 
通常は「UTF-8 BOMなし」で保存するものと思いますので、はるさんの仰るように、ファイルの保存形式を確認していただくと良いのかもしれません。
 
もしくは、BOMがphpファイルの中に貼り付けられてしまっているもかもしれないですね。

   
(@yoshiyoshi0210)
Active Member Registered
結合: 1年前
投稿: 2
Topic starter  

>はる様 MK2様

ご返信及び明確なアドバイス、ありがとうございます。

ご指摘頂いたように、テキストエディタ(terapad)の文字コードの保存設定を

UTF-8からUTF-8Nに変更したところ、無事に改行がなくなりました!

 

コードの記述云々以前の問題だったようでお恥ずかしい限りですが、非常に勉強になりました。

改めてお礼申し上げます。ありがとうございました!


   
共有:

問題の解決に至った場合には、トピック冒頭の「解決済み」をクリックしていただけますと幸いです。

また、有用な回答があった場合は返信右下にある「いいね!」もご活用ください。回答者の励みになります。

「いいね!」機能はフォーラム登録者のみが利用できる機能です。

CC BY-ND 2.1)準じていれば(リンクを貼っていただければ)転載も自由です。カスタマイズ記事を書く際にコード等をコピペ利用していただいて構いません。

フォーラムの使い方がよくわからない場合は、テストトピックで自由にテストしていただいて構いません。

最近の書き込みはこちら。

詳細なカスタマイズ依頼をするならこちら。

タイトルとURLをコピーしました