これで急場しのぎしました。ほかにもっとスマートな方法はなかったでしょうか?コクーンテーマだけ動作確認しています。
投稿に、なにか問題があったらごめんなさい。
@charset "utf-8";
/*
* 担当 Y.Syntarou
* 日付
* ステータス 実験
*/
.entry-card h2 {
text-align: left;
font-weight: bold;
font-size: 16px;
background: none;
border: none;
}
<?php
/*
Plugin Name: WhiteCat Category
Plugin URI:
Description: 複数カテゴリをインデックスする
Version: 0.1
Author: Y.Syntarou
Author URI:
*/
function call_whitecat_category($params = array()) {
$categories = get_categories();
$disp = array("event", "news", "information");
foreach ($categories as $category) {
if (in_array($category->slug, $disp) == false) {
continue;
}
$args = array(
'post_type' => 'post', // 投稿タイプ
'category_name' => $category->slug,
'posts_per_page' => 10, // 表示件数
);
$new_query = new WP_Query($args);
ob_start();
?>
<h1 class="wp-block-heading entry-title"><span class="fa fa-folder-open" aria-hidden="true"></span><?php echo $category->name ?></h1>
---権利問題がおきそうなので、省略しました。---
<?php wp_reset_postdata(); ?>
<?php endif;
}
$text = ob_get_contents();
ob_end_clean();
return $text;
}
function get_thumb_url($size = 'thumb320') {
$thumb_id = get_post_thumbnail_id();
$thumb_img = wp_get_attachment_image_src($thumb_id, $size);
$thumb_src = $thumb_img[0];
$thumb_alt = get_the_title();
return $thumb_src;
}
function theme_enqueue_whitecat_category() {
wp_enqueue_style( 'whitecat-category-style', plugins_url('whitecat-category/whitecat-category.css') );
}
add_action( 'wp_body_open', 'theme_enqueue_whitecat_category' );
add_shortcode('whitecat_category', 'call_whitecat_category');
?>