<ul class="homepage-category">
<?php
$prod_cat_args = array(
'taxonomy' => 'product_cat',
'orderby' => 'id',
'hide_empty' => true,
'parent' => 0
);
$woo_categories = get_categories( $prod_cat_args );
foreach ( $woo_categories as $woo_cat ) {
$woo_cat_id = $woo_cat->term_id;
$woo_cat_name = $woo_cat->name;
$woo_cat_slug = $woo_cat->slug;
echo '<li class="main-cat-item">';
$category_thumbnail_id = get_term_meta($woo_cat_id, 'thumbnail_id', true);
$thumbnail_image_url = wp_get_attachment_image_src( $category_thumbnail_id, 'medium')[0];
echo '<a href="' . get_term_link( $woo_cat_id, 'product_cat' ) . '"><img src="' . $thumbnail_image_url . '"/> <h4>' . $woo_cat_name . '</h4></a>';
echo "</li>\n";
}
?>
</ul>
$today = getdate();
//we set the variables, i am ignoring sticky posts so they dont get counted
$args = array(
'ignore_sticky_posts' => 1,
'posts_per_page' => -1, //all posts
'date_query' => array(
array(
'year' => $today["year"],
'month' => $today["mon"],
'day' => $today["mday"],
),
),
);
//we create the query
$today_posts = new WP_Query( $args );
//the result already has a property with the number of posts returned
$count = $today_posts->post_count;
//show it
echo $count;
$categories = get_categories('orderby=name&order=ASC&taxonomy=category');
foreach($categories as $category){
echo '<a href="' . get_category_link( $category->term_id ) . '">'. $category->name.' <span>('. $category->count .')</span></a>';
}
function my_scripts_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method', 11 );