我有一个按自定义分类过滤的 wordpress 页面列表。如何将其转换为 wp 函数以与简码一起使用?
这是工作过滤:
<?
$custom_terms = get_terms('csgroup');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'page', 'csgroup' => 'digital-expert-group',
// $args = array('post_type' => 'page', 'csgroup' => 'management-consultants-group',
'tax_query' => array(
array(
'taxonomy' => 'csgroup',
'field' => 'slug',
'terms' => $custom_term->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
echo '<h2>'.$custom_term->name.'</h2>';
while($loop->have_posts()) : $loop->the_post();
echo '<a href="'.get_permalink().'">'.get_the_title().'</a><br>';
endwhile;
}
}
wp_reset_postdata();
?>
我想得到这个:
function l1category_list_func(){
==my php code with list of pages==
}
add_shortcode( 'l1category_list', 'l1category_list_func' );
哔哔one