WordPress Popular Posts・フィルターフック・get_template_part()
-
WPPのpost_htmlフィルターを、get_template_part()でテンプレファイルを読み込み実現させたい。
投稿記事IDの取得方法がわからずにいます。◆functions.php
function my_custom_wpp($post_html) { global $post; $output = ''; ob_start(); if (is_page('name-a')) { get_template_part('template-a'); } elseif (is_page('name-b')) { get_template_part('template-b'); } $article = ob_get_contents($post->ID); ob_end_clean(); $output = $article; return $output; } add_filter('wpp_post', 'my_custom_wpp', 10, 3);
<?php $wpp = array( 'cat' => 1, 'limit' => 5, 'post_type' => 'post', 'range' => 'weekly', 'stats_comments' => '0', 'stats_views' => '0', ); wpp_get_mostpopular($wpp); ?>
8件の返信を表示中 - 1 - 8件目 (全8件中)
8件の返信を表示中 - 1 - 8件目 (全8件中)
- トピック「WordPress Popular Posts・フィルターフック・get_template_part()」には新たに返信することはできません。