'',
'date_modified' => 'no',
'date_class' => 'icp_date',
'numberposts' => $default_number_of_posts,
), $atts, 'catlist');
$args = array(
'posts_per_page' => intval($atts['numberposts']),
);
if (!empty($atts['name'])) {
$args['category_name'] = sanitize_text_field($atts['name']);
}
$query = new WP_Query($args);
$output = '
';
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$output .= '- ' . esc_html(get_the_title()) . '';
if (strtolower(sanitize_text_field($atts['date_modified'])) === 'yes') {
$output .= ' - ' . esc_html(get_the_modified_date()) . '';
}
$output .= '
';
}
} else {
$output .= '- ' . esc_html__('No posts found', 'advance-catlist-post') . '
';
}
$output .= '
';
wp_reset_postdata();
return $output;
}
add_shortcode('catlist', 'advance_catlist_post_shortcode');
// Add Settings Page
function advance_catlist_post_add_admin_menu() {
add_menu_page(
esc_html__('Advance Catlist Post', 'advance-catlist-post'),
esc_html__('Catlist Settings', 'advance-catlist-post'),
'manage_options',
'advance_catlist_post',
'advance_catlist_post_options_page',
'dashicons-admin-settings',
20
);
}
add_action('admin_menu', 'advance_catlist_post_add_admin_menu');
function advance_catlist_post_options_page() {
?>