Avoiding “Missed Schedule” errors when inserting future posts

The missed schedule warning comes form those lines: https://github.com/WordPress/WordPress/blob/f884d7973b052c3efe0901bb136b9898ece8aa39/wp-admin/includes/class-wp-posts-list-table.php#L998,L999 It should be independent on any cron event, as the warning is being displayed only in case the current UTC time – post_date_gmt > 0 – there is no other condition (except for post having the future status). In order to debug the issue, check what … Read more

How many posts does the loop return?

Try reversing the logic, put the dividing line before the post but only do it after the first post. To answer your question though, you can get the loop count with the following: global $wp_query; $count = count( $wp_query->posts ); // or $count = $wp_query->post_count;

Excluding posts not working

Have a look at https://codex.wordpress.org/Class_Reference/WP_Query, and maybe try passing your args in an array. Above page lists this exact example, which should work: // This WILL work $exclude_ids = array( 1, 2, 3 ); $query = new WP_Query( array( ‘post__not_in’ => $exclude_ids ) );

Insert sometext after first h3 in content

Note returning $content[0]; when !is_single() you’ll get non-exist errors. You can accomplish what you’re after with somthing like: add_filter(‘the_content’, function ($content){ if (!is_single()) return $content; $div = “🎅🏻”; return preg_replace(‘/<\/h3>/i’, “</h3>”.$div, $content, 1); }); note the third parameter of preg_replace() is the limit, setting to 1 will restrict the replace to the first match.

Which PHP page is the Default Posts Page

home.php is the file in the WordPress template hierarchy which is used for the posts page. However, after looking at the Twentyseventeen theme code on GitHub, there is no home.php file provided which means the index.php will be used instead. Within index.php Twentyseventeen then uses get_template_part to seperate reusable sections of code. The most general … Read more

Is it possible to add/tick a category to a post when it is created?

You can add a category on post creation with this code : $postType = “post”; add_action(“save_post_” . $postType, function ($post_ID, \WP_Post $post, $update) { if (!$update) { // default values for new posts $post_categories = [get_option(“default_category”)]; wp_set_post_terms( $post->ID , $post_categories , “category” ); return; } // here, operations for updated posts }, 10, 3);

Worpdress function for difference dates

Put this in the appropriate template. <?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?> Normally the php file you should look for would be entry-meta.php Remember to use a child theme..

Internal post link creates comments on its own

This kind of automatic comments are called “trackbacks” and “pingbacks”. They are a blogging feature that consists of automatically notifying blogs that are linked to from an article when said article is published. This notification appears as a kind of comment on the mentionned article, with a link pointing back to the newly published one. … Read more