これは簡単かもしれませんが、私はまだWPとPHPに少し慣れていないので、これを理解できません.
もともと、このページは最近の投稿を 1 つのカテゴリからさまざまな列のグループにまとめていました。これは、カスタム関数を使用してうまく実行できました。
category_loop('columns', 'Recent Articles', 4);
function category_loop($id, $name, $number)
カテゴリ ID は列、セクションのタイトルは最近の投稿で、合計 4 件の投稿がありました。
さて、今では、「列」と「コメント」の 2 つのカテゴリからプルする必要があります。現在のコードをすべて書き直すことなく、配列 (または何か) を使用して許可する方法があるかどうか疑問に思っていました。関数で使用される 2 つのカテゴリ $id 用。
必要に応じてさらにコードを提供できます。
本当にありがとう!
編集:関数自体は次のとおりです。
}
function category_loop($id, $name, $number){
$weather = get_category_by_slug('the-weather');
$acupuncture = get_category_by_slug('acupuncture-after-the-apocalypse');
$letters = get_category_by_slug('letters-from-the-editors');
?>
<div class="category-block">
<div class="category-block-title">
<div style="margin-top: 4px;">
<?php echo $name ?>
</div>
</div>
<div id="<?php echo $id ?>-posts" class="category-post-loop">
<?php
remove_action('genesis_post_content', 'genesis_do_post_content');
add_action('genesis_post_content', 'do_post_excerpt');
add_filter('genesis_post_title', 'trop_byline_short');
// Columns -- be sure to remove featured posts
$args = array( 'category_name' => $id, 'cat' => '-'.$weather->cat_ID.',-'
.$acupuncture->cat_ID.',-'.$letters->cat_ID, 'orderby' => 'date',
'posts_per_page' => $number, 'meta_query' => array(array( 'key' => 'featured',
'compare' => 'NOT EXISTS' )) );
genesis_custom_loop( $args );
remove_filter('genesis_post_title', 'trop_byline_short');
add_action('genesis_post_content', 'genesis_do_post_content');
remove_action('genesis_post_content', 'do_post_excerpt');
?>