Why does ‘get_the_ID’ work outside of the loop?

The get_the_ID() function uses the global $post variable, which outside of the loop is sometimes equal to get_queried_object_id(). Within the loop, the $post variable is set to the current post within the loop. As to why get_queried_object_id() is recommended outside of the loop, is because it does not use the global $post variable, so is … Read more

Content Restriction but allow public REST API

You can use the REST_REQUEST constant to detect if this is a REST request, and if it’s not, apply your filter(s). Example: add_filter( ‘the_content’, ‘wpse418531_use_excerpt’ ); /** * Replaces the content with the excerpt, unless this is a REST request. * * @param string $content The post content. * @return string The filtered post content. … Read more

Stiff-necked themes

It is wise to have at least one standard theme installed, because it will always work. If your current theme, for whatever reason, no longer works with the current WordPress install, you will have a backup theme to get your site running again. That said, you are not the first to complain about this and … Read more

Style.css file gets restored to default version

Below is a generic response to help you, but first I want to give you my personal opinions based on my experiences with issues regarding using stylesheets with WordPress. I never use the themes generic style.css file due to issues like this and other common issues. Google no longer penalizes you for having extra .css … Read more

Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?

Yes, but you have to do it Redux- way. Subscribe to post saving action (there are separate actions for save and auto-save) and dispatch a message using dispatch function. Edit: Inside blocks, there are better hooks to use, like useSelect. But, outside the block, in general block editor environmentm you have to use subscribe. In … Read more