WordPress website loads more posts than expected

The theme is most likely altering the main query via the pre_get_posts hook, chaning the posts_per_page argument to -1 for all posts, or another higher number. You can search your theme folder for pre_get_posts to see all the times this hook is used. A better solution would be to install the Query Monitor. With this … Read more

Count posts on multisite with blog id

In order to use wp_count_posts() as you would on a single site, pass the blog id into the switch_to_blog() function before calling wp_count_posts(). Example: function wpse_get_post_count( $blog_id ){ switch_to_blog( $blog_id ); $post_count = wp_count_posts(); restore_current_blog(); return $post_count; } Ensure restore_current_blog() is used after every switch_to_blog() or you will risk difficulties mentioned in the notes section … Read more

Delete post after x minutes if user role is

This is a simple question, but it involves quite some work, so I’ll just give you an outline: First, you need to define a cron job that runs every minute or so. This will allow you to define an action that is run automatically. Beware that this will run only when the site is visited, … Read more

Is it possible to customize the post according to post format in single.php?

Yes, it is possible. The easiest and very readable way would be to do this like TwentyX themes do – using get_post_format and get_template_part functions. Let’s say that your current single.php file looks something like this: <?php get_header(); ?> … <?php while ( have_posts() ) : the_post; ?> <article …> … </article> <?php endwhile; ?> … Read more

Fixing paragraph spacing in posts

You can add the following code in your CSS. (Considering that you are using h1) h1 { padding-top: 5px; } You can see / play with the same sample on https://codepen.io/ankyit/pen/NzRjrL