When trashing a post, also trash related comments

Well, this is partly true and partly false. When you trash a post, everything that is tied to it is also trashed. This means, if you untrash the post, the comments etc. are untrashed as well. However, comments and other stuff is not handled as if they were trashed directly (i.e., on the Comments page … Read more

Check is_single() outside loop

In your example, you can’t. Per the Codex, [is_single()] checks if a single post of any post type except attachment and page post types is being displayed. You’re trying to use it on the transition_post_status hook, which is not related to page display, and so is_single() has no meaning. The Solution Instead of using is_single(), … Read more

Reset/Reorder posts ID in the MySQL wp_posts table

If you want sequential numbers for your posts, then don’t use the post ID column. AUTO_INCREMENT is meant to provide unique numbers (and split-brains in multi-master replication), it is never going to be without gaps, especially not in WordPress (revisions, autosaves, pages, contact forms, galleries and a bunch of other plugins) and especially not with … Read more

How to disable single post view in wp

You can add to the end of theme’s header.php file this: if( is_single() ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); get_template_part( ‘404’ ); exit(); } Note that the get_template_part( ‘404’ ) function needs 404.php file in your theme directory.

How to Use PHP Code In-Page?

There is almost never a scenario where executing PHP code entered from the wysiwyg editor is a good idea. It opens up a whole bunch of security issues. The best way to achieve what you are looking for is to setup a custom short code that will return the link you are interested in. Add … Read more