List category postsプラグインで投稿の個別記事に投稿リストをLightningと同じデザインで表示する
Wordpress テーマ Lightningでの例
投稿の個別記事に、カテゴリ・タグ別で投稿のリストをLightningと同じデザインで表示しました。
LTG コンテンツエリア投稿リスト ウィジェット を流用すれば同じ表示にできるのかもしれませんが。
- List category postsプラグインを使用します。
https://wordpress.org/plugins/list-category-posts/
module_loop_post_meta.phpを編集して、リスト表示に複数のカテゴリーを表示する方法のコードに変更します。CSSも変更します。
テーマLightningでカテゴリーを複数表示するようにカスタマイズしました
https://usortblog.com/lightning-multiple-categories-2/- List category postsプラグインでの操作
my_cat_list.phpを作成して下記のコードを書きます。タグも表示したいのですがまだできていません。
<?php /* Plugin Name: List Category Posts - Template "Default" Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/ Description: Template file for List Category Post Plugin for WordPress which is used by plugin by argument template=value.php Version: 0.9 Author: Radek Uldrych & Fernando Briano Author URI: http://picandocodigo.net http://radoviny.net */ /* Copyright 2009 Radek Uldrych (email : verex@centrum.cz) Copyright 2009-2015 Fernando Briano (http://picandocodigo.net) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * The format for templates changed since version 0.17. Since this * code is included inside CatListDisplayer, $this refers to the * instance of CatListDisplayer that called this file. */ /* This is the string which will gather all the information.*/ $lcp_display_output = ''; // Show the conditional title: $lcp_display_output .= $this->get_conditional_title(); //Add 'starting' tag. Here, I'm using an unordered list (ul) as an example: $lcp_display_output .= "<div>"; /* Posts Loop * * The code here will be executed for every post in the category. As * you can see, the different options are being called from functions * on the $this variable which is a CatListDisplayer. * * CatListDisplayer has a function for each field we want to show. So * you'll see get_excerpt, get_thumbnail, etc. You can now pass an * html tag as a parameter. This tag will sorround the info you want * to display. You can also assign a specific CSS class to each field. */ global $post; while ( have_posts() ): the_post(); //Start a List Item for each post: $lcp_display_output .= '<article class="media">'; $lcp_display_output .= '<div>'; //Post Thumbnail $lcp_display_output .= '<div class="postList_thumbnail">'; $lcp_display_output .= $this->get_thumbnail($post); $lcp_display_output .= '</div>'; $lcp_display_output .= '<div class="media-body">'; $lcp_display_output .= '<div class="entry-meta">'; //Show date: $lcp_display_output .= '<span class="published entry-meta_items">'; $lcp_display_output .= $this->get_date($post); $lcp_display_output .= '</span>'; // Show category link: $lcp_display_output .= '<span class="entry-meta_items entry-meta_items_term">'; $catlink = $this->get_category_link(); $lcp_display_output .= substr_replace($catlink, ' class="btn btn-xs btn-primary"', 2, 0); $lcp_display_output .= '</span>'; //Show the title and link to the post: $lcp_display_output .= '<h1 class="media-heading entry-title">'; $lcp_display_output .= $this->get_post_title($post); $lcp_display_output .= '</h1></div>'; //Show comments: $lcp_display_output .= $this->get_comments($post); //Show date modified: $lcp_display_output .= ' ' . $this->get_modified_date($post); //Show author $lcp_display_output .= $this->get_author($post); //Custom fields: $lcp_display_output .= $this->get_custom_fields($post); /** * Post content - Example of how to use tag and class parameters: * This will produce:<p class="lcp_content">The content</p> */ /** $lcp_display_output .= $this->get_content($post, 'a', 'media-body_excerpt'); */ /** * Post content - Example of how to use tag and class parameters: * This will produce:<div class="lcp_excerpt">The content</div> */ $lcp_display_output .= '<p>'; $lcp_display_output .= $this->get_excerpt($post, 'a', 'media-body_excerpt'); $lcp_display_output .= '</p>'; // Get Posts "More" link: $lcp_display_output .= $this->get_posts_morelink($post); //Pagination $lcp_display_output .= '<p>'; $lcp_display_output .= $this->get_pagination(); $lcp_display_output .= '</p>'; //Close li tag $lcp_display_output .= '</div>'; $lcp_display_output .= '</article>'; endwhile; // Close the wrapper I opened at the beginning: $lcp_display_output .= '</div>'; // If there's a "more link", show it: $lcp_display_output .= $this->get_morelink(); // Get category posts count $lcp_display_output .= $this->get_category_count(); $this->lcp_output = $lcp_display_output;
投稿の個別記事に下記のList category postsプラグインのショートコードを自由に書きます。
ショートコードは1投稿で、カテゴリ・タグ別にいくつも書け、表示する投稿数も指定できるので[catlist name="ongoing" tags="higashi-murayama" category_description="yes" thumbnail="yes" date="yes" dateformat="Y年Fj日" order=asc catlink="yes" excerpt="yes" excerpt_size="280" pagination="yes" template=my_cat_list]
投稿にカテゴリ別のリストを下記のように表示できます(カテゴリのON/OFFによる手動でのイベント管理)。
東京で予定中
東京で開催中
東京で開催終了
0 件のコメント:
コメントを投稿