List of published post dates only outputting one date

you are overwriting the $testlist variable in each iteration of the loop. You need to concatenate each date to $testlist instead. please try to fetch all posts from the past year and create a js array containing their dates and make sure to call the test() function where you want this script to be executed … Read more

Hide load more button if no more post in selected category

I believe you should pass one more label “How many posts remain to be seen” in your $response array in function filterPosts() You know the total number of posts based WP_Query that exist in the database $filter_query = new WP_Query($filter_args); $total_query_posts = $filter_query->found_posts; So, then you have to calculate it based on paged and posts_per_page, … Read more

Error counting posts of category

Every time you step through the outermost foreach() loop, your $total_count gets reset. Try this: $categories = get_categories([ ‘hide_empty’ => 0, ‘parent’ => 0, ]); $total_count = 0; foreach ($categories as $category) { $subcategories = get_categories([ ‘hide_empty’ => 0, ‘parent’ => $category->term_id, ]); $total_count += $category->count; // Adds the main category count foreach ($subcategories as … Read more

Insert Tag in WordPress Post

If you are using wp_set_post_tags this you can pass either array of exiting tags id or array of string. If it is a string then it will create a new one and assign that, if you are passing an id then it will assign that term_id of post_tag. As per your code I can see … Read more